mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Add reblog and reply notifications
This commit is contained in:
parent
be9b2e3376
commit
82162fccf4
|
|
@ -436,6 +436,19 @@ export const createNewStatus = async (data: {
|
|||
include: statusAndUserRelations,
|
||||
});
|
||||
|
||||
// Create notification
|
||||
|
||||
if (status.inReplyToPost) {
|
||||
await client.notification.create({
|
||||
data: {
|
||||
notifiedId: status.inReplyToPost.authorId,
|
||||
accountId: status.authorId,
|
||||
type: "mention",
|
||||
statusId: status.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,18 @@ export default async (
|
|||
include: statusAndUserRelations,
|
||||
});
|
||||
|
||||
// Create notification for reblog if reblogged user is on the same instance
|
||||
if (status.reblog?.author.instanceId === user.instanceId) {
|
||||
await client.notification.create({
|
||||
data: {
|
||||
accountId: user.id,
|
||||
notifiedId: status.reblog.authorId,
|
||||
type: "reblog",
|
||||
statusId: status.reblogId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return jsonResponse(
|
||||
await statusToAPI(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import {
|
|||
} from "~database/entities/Status";
|
||||
import { parseMentionsUris, userRelations } from "~database/entities/User";
|
||||
import type {
|
||||
Announce,
|
||||
LysandAction,
|
||||
LysandPublication,
|
||||
Patch,
|
||||
|
|
@ -274,8 +275,43 @@ export default async (
|
|||
break;
|
||||
}
|
||||
case "Announce": {
|
||||
const announce = body as Announce;
|
||||
// Store the object in the LysandObject table
|
||||
await createFromObject(body);
|
||||
|
||||
const rebloggedStatus = await client.status.findUnique({
|
||||
where: {
|
||||
uri: announce.object,
|
||||
},
|
||||
include: statusAndUserRelations,
|
||||
});
|
||||
|
||||
if (!rebloggedStatus) {
|
||||
return errorResponse("Status not found", 404);
|
||||
}
|
||||
|
||||
// Create new reblog
|
||||
const newReblog = await client.status.create({
|
||||
data: {
|
||||
authorId: author.id,
|
||||
reblogId: rebloggedStatus.id,
|
||||
isReblog: true,
|
||||
uri: body.uri,
|
||||
visibility: rebloggedStatus.visibility,
|
||||
sensitive: false,
|
||||
},
|
||||
include: statusAndUserRelations,
|
||||
});
|
||||
|
||||
// Create notification
|
||||
await client.notification.create({
|
||||
data: {
|
||||
accountId: author.id,
|
||||
notifiedId: rebloggedStatus.authorId,
|
||||
type: "reblog",
|
||||
statusId: rebloggedStatus.id,
|
||||
},
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "Undo": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue