stacker.news/api/typeDefs/notifications.js
ekzyis 2597eb56f3
Item mention notifications (#1208)
* Parse internal refs to links

* Item mention notifications

* Also parse item mentions as URLs

* Fix subType determined by referrer item instead of referee item

* Ignore subType

Considering if the item that was referred to was a post or comment made the code more complex than initially necessary.

For example, notifications for /notifications are deduplicated based on item id and the same item could refer to posts and comments, so to include "one of your posts" or "one of your comments" in the title would require splitting notifications based on the type of referred item.

I didn't want to do this but also wanted to have consistent notification titles between push and /notifications, so I use "items" in both places now, even though I think using "items" isn't ideal from a user perspective. I think it might be confusing.

* Fix rootText

* Replace full links to #<id> syntax in push notifications

* Refactor mention code into separate functions
2024-06-03 12:12:42 -05:00

155 lines
2.4 KiB
JavaScript

import { gql } from 'graphql-tag'
export default gql`
extend type Query {
notifications(cursor: String, inc: String): Notifications
}
extend type Mutation {
savePushSubscription(endpoint: String!, p256dh: String!, auth: String!, oldEndpoint: String): PushSubscription
deletePushSubscription(endpoint: String!): PushSubscription
}
type Votification {
id: ID!
earnedSats: Int!
item: Item!
sortTime: Date!
}
type ForwardedVotification {
id: ID!
earnedSats: Int!
item: Item!
sortTime: Date!
}
type FollowActivity {
id: ID!
item: Item!
sortTime: Date!
}
type Reply {
id: ID!
item: Item!
sortTime: Date!
}
type Mention {
id: ID!
mention: Boolean!
item: Item!
sortTime: Date!
}
type ItemMention {
id: ID!
item: Item!
sortTime: Date!
}
type Invitification {
id: ID!
invite: Invite!
sortTime: Date!
}
type JobChanged {
id: ID!
item: Item!
sortTime: Date!
}
type EarnSources {
id: ID!
posts: Int!
comments: Int!
tipPosts: Int!
tipComments: Int!
}
type Streak {
id: ID!
sortTime: Date!
days: Int
}
type Earn {
id: ID!
earnedSats: Int!
minSortTime: Date!
sortTime: Date!
sources: EarnSources
}
type Revenue {
id: ID!
earnedSats: Int!
sortTime: Date!
subName: String!
}
type InvoicePaid {
id: ID!
earnedSats: Int!
invoice: Invoice!
sortTime: Date!
}
type WithdrawlPaid {
id: ID!
earnedSats: Int!
sortTime: Date!
withdrawl: Withdrawl!
}
type Referral {
id: ID!
sortTime: Date!
}
type SubStatus {
id: ID!
sub: Sub!
sortTime: Date!
}
type TerritoryPost {
id: ID!
item: Item!
sortTime: Date!
}
type TerritoryTransfer {
id: ID!
sub: Sub!
sortTime: Date!
}
type Reminder {
id: ID!
item: Item!
sortTime: Date!
}
union Notification = Reply | Votification | Mention
| Invitification | Earn | JobChanged | InvoicePaid | WithdrawlPaid | Referral
| Streak | FollowActivity | ForwardedVotification | Revenue | SubStatus
| TerritoryPost | TerritoryTransfer | Reminder | ItemMention
type Notifications {
lastChecked: Date
cursor: String
notifications: [Notification!]!
}
type PushSubscription {
id: ID!
userId: ID!
endpoint: String!
p256dh: String!
auth: String!
}
`