mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Add notifications for follow requests again and mentions
This commit is contained in:
parent
06bcbbe451
commit
47133ac3fe
4 changed files with 138 additions and 5 deletions
|
|
@ -35,6 +35,7 @@ import {
|
|||
status,
|
||||
statusToMentions,
|
||||
user,
|
||||
notification,
|
||||
} from "~drizzle/schema";
|
||||
import { LogLevel } from "~packages/log-manager";
|
||||
import type { Note } from "~types/lysand/Object";
|
||||
|
|
@ -995,6 +996,18 @@ export const createNewStatus = async (
|
|||
.where(inArray(attachment.id, media_attachments));
|
||||
}
|
||||
|
||||
// Send notifications for mentioned local users
|
||||
for (const mention of mentions ?? []) {
|
||||
if (mention.instanceId === null) {
|
||||
await db.insert(notification).values({
|
||||
accountId: author.id,
|
||||
notifiedId: mention.id,
|
||||
type: "mention",
|
||||
statusId: newStatus.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
(await findFirstStatuses({
|
||||
where: (status, { eq }) => eq(status.id, newStatus.id),
|
||||
|
|
@ -1146,6 +1159,18 @@ export const editStatus = async (
|
|||
.execute();
|
||||
}
|
||||
|
||||
// Send notifications for mentioned local users
|
||||
for (const mention of mentions ?? []) {
|
||||
if (mention.instanceId === null) {
|
||||
await db.insert(notification).values({
|
||||
accountId: statusToEdit.authorId,
|
||||
notifiedId: mention.id,
|
||||
type: "mention",
|
||||
statusId: updated.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Set attachment parents
|
||||
await db
|
||||
.update(attachment)
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ export const followRequestUser = async (
|
|||
notify = false,
|
||||
languages: string[] = [],
|
||||
): Promise<InferSelectModel<typeof relationship>> => {
|
||||
const isRemote = follower.instanceId !== followee.instanceId;
|
||||
const isRemote = followee.instanceId !== null;
|
||||
|
||||
const updatedRelationship = (
|
||||
await db
|
||||
|
|
@ -226,9 +226,9 @@ export const followRequestUser = async (
|
|||
}
|
||||
} else {
|
||||
await db.insert(notification).values({
|
||||
accountId: followee.id,
|
||||
accountId: follower.id,
|
||||
type: followee.isLocked ? "follow_request" : "follow",
|
||||
notifiedId: follower.id,
|
||||
notifiedId: followee.id,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue