Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { getApId } from "../type.js";
|
||||
import { isSelfHost, extractDbHost } from "../../../misc/convert-host.js";
|
||||
import { MessagingMessages } from "../../../models/index.js";
|
||||
import { readUserMessagingMessage } from "../../../server/api/common/read-messaging-message.js";
|
||||
export const performReadActivity = async (actor, activity)=>{
|
||||
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.findOneBy({
|
||||
id: 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})`;
|
||||
};
|
||||
Reference in New Issue
Block a user