activitypub: no longer deliver chat read
Prospectively, the messaging messages will be removed as objects so it does not make sense to refactor this to match the remainder of refactoring away the user from deliver. It is just easier to remove this use of delivering something that is not an activity. Changelog: Removed
This commit is contained in:
parent
07891db78e
commit
d292f035aa
4 changed files with 2 additions and 42 deletions
|
@ -1,9 +0,0 @@
|
|||
import config from '@/config/index.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { MessagingMessage } from '@/models/entities/messaging-message.js';
|
||||
|
||||
export const renderReadActivity = (user: { id: User['id'] }, message: MessagingMessage) => ({
|
||||
type: 'Read',
|
||||
actor: `${config.url}/users/${user.id}`,
|
||||
object: message.uri,
|
||||
});
|
|
@ -7,10 +7,6 @@ import { MessagingMessages, UserGroupJoinings, Users } from '@/models/index.js';
|
|||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { UserGroup } from '@/models/entities/user-group.js';
|
||||
import { toArray } from '@/prelude/array.js';
|
||||
import { renderReadActivity } from '@/remote/activitypub/renderer/read.js';
|
||||
import { renderActivity } from '@/remote/activitypub/renderer/index.js';
|
||||
import { deliver } from '@/queue/index.js';
|
||||
import orderedCollection from '@/remote/activitypub/renderer/ordered-collection.js';
|
||||
|
||||
/**
|
||||
* Mark messages as read
|
||||
|
@ -133,18 +129,3 @@ export async function readGroupMessagingMessage(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function deliverReadActivity(user: { id: User['id']; host: null; }, recipient: IRemoteUser, messages: MessagingMessage | MessagingMessage[]) {
|
||||
const contents = toArray(messages)
|
||||
.filter(x => x.uri)
|
||||
.map(x => renderReadActivity(user, x));
|
||||
|
||||
if (contents.length > 1) {
|
||||
const collection = orderedCollection(null, contents.length, undefined, undefined, contents);
|
||||
deliver(renderActivity(collection), recipient.inbox);
|
||||
} else {
|
||||
for (const content of contents) {
|
||||
deliver(renderActivity(content), recipient.inbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import define from '@/server/api/define.js';
|
|||
import { ApiError } from '@/server/api/error.js';
|
||||
import { getUser } from '@/server/api/common/getters.js';
|
||||
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
|
||||
import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '@/server/api/common/read-messaging-message.js';
|
||||
import { readUserMessagingMessage, readGroupMessagingMessage } from '@/server/api/common/read-messaging-message.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['messaging'],
|
||||
|
@ -75,11 +75,6 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
// Mark all as read
|
||||
if (ps.markAsRead) {
|
||||
readUserMessagingMessage(user.id, recipient.id, messages.filter(m => m.recipientId === user.id).map(x => x.id));
|
||||
|
||||
// リモートユーザーとのメッセージだったら既読配信
|
||||
if (Users.isLocalUser(user) && Users.isRemoteUser(recipient)) {
|
||||
deliverReadActivity(user, recipient, messages);
|
||||
}
|
||||
}
|
||||
|
||||
return await Promise.all(messages.map(message => MessagingMessages.pack(message, user, {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { UserGroupJoinings, Users, MessagingMessages } from '@/models/index.js';
|
||||
import { User, ILocalUser, IRemoteUser } from '@/models/entities/user.js';
|
||||
import { UserGroup } from '@/models/entities/user-group.js';
|
||||
import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '@/server/api/common/read-messaging-message.js';
|
||||
import { readUserMessagingMessage, readGroupMessagingMessage } from '@/server/api/common/read-messaging-message.js';
|
||||
import Channel from '@/server/api/stream/channel.js';
|
||||
import { StreamMessages } from '@/server/api/stream/types.js';
|
||||
|
||||
|
@ -69,13 +69,6 @@ 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.findOneBy({ id: 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]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue