d071d18dd7
* wip * wip * fix * clean up * Update tsconfig.json * Update activitypub.ts * wip
23 lines
895 B
TypeScript
23 lines
895 B
TypeScript
import renderUpdate from '@/remote/activitypub/renderer/update.js';
|
|
import { renderActivity } from '@/remote/activitypub/renderer/index.js';
|
|
import renderNote from '@/remote/activitypub/renderer/note.js';
|
|
import { Users, Notes } from '@/models/index.js';
|
|
import { Note } from '@/models/entities/note.js';
|
|
import { deliverToFollowers } from '@/remote/activitypub/deliver-manager.js';
|
|
import { deliverToRelays } from '../../relay.js';
|
|
|
|
export async function deliverQuestionUpdate(noteId: Note['id']) {
|
|
const note = await Notes.findOne(noteId);
|
|
if (note == null) throw new Error('note not found');
|
|
|
|
const user = await Users.findOne(note.userId);
|
|
if (user == null) throw new Error('note not found');
|
|
|
|
if (Users.isLocalUser(user)) {
|
|
|
|
const content = renderActivity(renderUpdate(await renderNote(note, false), user));
|
|
deliverToFollowers(user, content);
|
|
deliverToRelays(user, content);
|
|
}
|
|
}
|