2021-08-19 14:55:45 +02:00
|
|
|
import renderUpdate from '@/remote/activitypub/renderer/update';
|
|
|
|
import { renderActivity } from '@/remote/activitypub/renderer/index';
|
|
|
|
import renderNote from '@/remote/activitypub/renderer/note';
|
|
|
|
import { Users, Notes } from '@/models/index';
|
|
|
|
import { Note } from '@/models/entities/note';
|
|
|
|
import { deliverToFollowers } from '@/remote/activitypub/deliver-manager';
|
|
|
|
import { deliverToRelays } from '../../relay';
|
2019-03-07 13:19:32 +01:00
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
export async function deliverQuestionUpdate(noteId: Note['id']) {
|
|
|
|
const note = await Notes.findOne(noteId);
|
2019-04-13 21:17:24 +02:00
|
|
|
if (note == null) throw new Error('note not found');
|
2019-03-07 13:19:32 +01:00
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
const user = await Users.findOne(note.userId);
|
2019-04-13 21:17:24 +02:00
|
|
|
if (user == null) throw new Error('note not found');
|
2019-03-07 13:19:32 +01:00
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
if (Users.isLocalUser(user)) {
|
2019-03-07 13:19:32 +01:00
|
|
|
|
2019-11-09 10:51:54 +01:00
|
|
|
const content = renderActivity(renderUpdate(await renderNote(note, false), user));
|
|
|
|
deliverToFollowers(user, content);
|
2020-05-10 11:42:31 +02:00
|
|
|
deliverToRelays(user, content);
|
2019-03-07 13:19:32 +01:00
|
|
|
}
|
|
|
|
}
|