Skip to content

Commit

Permalink
send mark-read-generic notification on updateSeen
Browse files Browse the repository at this point in the history
add `reason`

add `recipientDid`

push `mark-read-generic` notification on `updateSeen`

add `client_controlled`
  • Loading branch information
haileyok committed Jun 9, 2024
1 parent 6e323fb commit cb3fc14
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/bsky/proto/courier.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ message Notification {
bool always_deliver = 6;
google.protobuf.Timestamp timestamp = 7;
google.protobuf.Struct additional = 8;
bool client_controlled = 9;
}

message PushNotificationsRequest {
Expand Down
17 changes: 16 additions & 1 deletion packages/bsky/src/api/app/bsky/notification/updateSeen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Timestamp } from '@bufbuild/protobuf'
import { Struct, Timestamp } from '@bufbuild/protobuf'
import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'

Expand All @@ -12,6 +12,21 @@ export default function (server: Server, ctx: AppContext) {
actorDid: viewer,
timestamp: Timestamp.fromDate(new Date(seenAt)),
})
await ctx.courierClient.pushNotifications({
notifications: [
{
id: 'mark-read-generic',
clientControlled: true,
recipientDid: viewer,
alwaysDeliver: true,
collapseKey: 'mark-read-generic',
timestamp: Timestamp.fromDate(new Date()),
additional: Struct.fromJson({
reason: 'mark-read-generic',
}),
},
],
})
},
})
}
11 changes: 11 additions & 0 deletions packages/bsky/src/proto/courier_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ export class Notification extends Message<Notification> {
*/
additional?: Struct

/**
* @generated from field: bool client_controlled = 9;
*/
clientControlled = false

constructor(data?: PartialMessage<Notification>) {
super()
proto3.util.initPartial(data, this)
Expand Down Expand Up @@ -206,6 +211,12 @@ export class Notification extends Message<Notification> {
},
{ no: 7, name: 'timestamp', kind: 'message', T: Timestamp },
{ no: 8, name: 'additional', kind: 'message', T: Struct },
{
no: 9,
name: 'client_controlled',
kind: 'scalar',
T: 8 /* ScalarType.BOOL */,
},
])

static fromBinary(
Expand Down

0 comments on commit cb3fc14

Please sign in to comment.