diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-12-15 03:37:19 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-12-15 03:37:19 +0900 |
| commit | 3e85aad80a882abc764c13a0fc40e3333bb61c4b (patch) | |
| tree | c4ef1a407e5a714dda25cb907bc4d40acb89ec26 /src/remote/activitypub/kernel/read.ts | |
| parent | Fix #5637 (#5638) (diff) | |
| download | sharkey-3e85aad80a882abc764c13a0fc40e3333bb61c4b.tar.gz sharkey-3e85aad80a882abc764c13a0fc40e3333bb61c4b.tar.bz2 sharkey-3e85aad80a882abc764c13a0fc40e3333bb61c4b.zip | |
Implement Talk has read federation (#5636)
* Talk read
* fix
* 複数のRead ActivityはCollectionとして送るように
* あ
Diffstat (limited to 'src/remote/activitypub/kernel/read.ts')
| -rw-r--r-- | src/remote/activitypub/kernel/read.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/remote/activitypub/kernel/read.ts b/src/remote/activitypub/kernel/read.ts new file mode 100644 index 0000000000..e4049fa7ef --- /dev/null +++ b/src/remote/activitypub/kernel/read.ts @@ -0,0 +1,27 @@ +import { IRemoteUser } from '../../../models/entities/user'; +import { IRead, getApId } from '../type'; +import { isSelfHost, extractDbHost } from '../../../misc/convert-host'; +import { MessagingMessages } from '../../../models'; +import { readUserMessagingMessage } from '../../../server/api/common/read-messaging-message'; + +export const performReadActivity = async (actor: IRemoteUser, activity: IRead): Promise<string> => { + const id = await getApId(activity.object); + + if (!isSelfHost(extractDbHost(id))) { + return `skip: Read to foreign host (${id})`; + } + + const messageId = id.split('/').pop(); + + const message = await MessagingMessages.findOne(messageId); + if (message == null) { + return `skip: message not found`; + } + + if (actor.id != message.recipientId) { + return `skip: actor is not a message recipient`; + } + + await readUserMessagingMessage(message.recipientId!, message.userId, [message.id]); + return `ok: mark as read (${message.userId} => ${message.recipientId} ${message.id})`; +}; |