undo announce
This commit is contained in:
parent
c9aa7646d2
commit
2a3e45456e
1 changed files with 27 additions and 4 deletions
|
@ -3,6 +3,13 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js";
|
|||
import type { IAnnounce } from "../../type.js";
|
||||
import { getApId } from "../../type.js";
|
||||
import deleteNote from "@/services/note/delete.js";
|
||||
import {
|
||||
type ScyllaNote,
|
||||
scyllaClient,
|
||||
prepared,
|
||||
parseScyllaNote,
|
||||
} from "@/db/scylla.js";
|
||||
import type { Note } from "@/models/entities/note.js";
|
||||
|
||||
export const undoAnnounce = async (
|
||||
actor: CacheableRemoteUser,
|
||||
|
@ -10,10 +17,26 @@ export const undoAnnounce = async (
|
|||
): Promise<string> => {
|
||||
const uri = getApId(activity);
|
||||
|
||||
const note = await Notes.findOneBy({
|
||||
uri,
|
||||
userId: actor.id,
|
||||
});
|
||||
let note: Note | ScyllaNote | null = null;
|
||||
|
||||
if (scyllaClient) {
|
||||
const result = await scyllaClient.execute(
|
||||
prepared.note.select.byUri,
|
||||
[uri],
|
||||
{ prepare: true },
|
||||
);
|
||||
if (result.rowLength > 0) {
|
||||
const candidate = parseScyllaNote(result.first());
|
||||
if (candidate.userId === actor.id) {
|
||||
note = candidate;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
note = await Notes.findOneBy({
|
||||
uri,
|
||||
userId: actor.id,
|
||||
});
|
||||
}
|
||||
|
||||
if (!note) return "skip: no such Announce";
|
||||
|
||||
|
|
Loading…
Reference in a new issue