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