summaryrefslogtreecommitdiff
path: root/src/server/api/stream/channels/messaging.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2019-12-15 03:37:19 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-12-15 03:37:19 +0900
commit3e85aad80a882abc764c13a0fc40e3333bb61c4b (patch)
treec4ef1a407e5a714dda25cb907bc4d40acb89ec26 /src/server/api/stream/channels/messaging.ts
parentFix #5637 (#5638) (diff)
downloadsharkey-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/server/api/stream/channels/messaging.ts')
-rw-r--r--src/server/api/stream/channels/messaging.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/server/api/stream/channels/messaging.ts b/src/server/api/stream/channels/messaging.ts
index 1e5e94c1c8..8456871e6a 100644
--- a/src/server/api/stream/channels/messaging.ts
+++ b/src/server/api/stream/channels/messaging.ts
@@ -1,7 +1,8 @@
import autobind from 'autobind-decorator';
-import { readUserMessagingMessage, readGroupMessagingMessage } from '../../common/read-messaging-message';
+import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '../../common/read-messaging-message';
import Channel from '../channel';
-import { UserGroupJoinings } from '../../../../models';
+import { UserGroupJoinings, Users, MessagingMessages } from '../../../../models';
+import { User, ILocalUser, IRemoteUser } from '../../../../models/entities/user';
export default class extends Channel {
public readonly chName = 'messaging';
@@ -9,11 +10,13 @@ export default class extends Channel {
public static requireCredential = true;
private otherpartyId: string | null;
+ private otherparty?: User;
private groupId: string | null;
@autobind
public async init(params: any) {
this.otherpartyId = params.otherparty as string;
+ this.otherparty = await Users.findOne({ id: this.otherpartyId });
this.groupId = params.group as string;
// Check joining
@@ -44,6 +47,13 @@ export default class extends Channel {
case 'read':
if (this.otherpartyId) {
readUserMessagingMessage(this.user!.id, this.otherpartyId, [body.id]);
+
+ // リモートユーザーからのメッセージだったら既読配信
+ if (Users.isLocalUser(this.user!) && Users.isRemoteUser(this.otherparty!)) {
+ MessagingMessages.findOne(body.id).then(message => {
+ if (message) deliverReadActivity(this.user as ILocalUser, this.otherparty as IRemoteUser, message);
+ });
+ }
} else if (this.groupId) {
readGroupMessagingMessage(this.user!.id, this.groupId, [body.id]);
}