2018-09-01 13:17:30 +02:00
|
|
|
import renderUpdate from '../../remote/activitypub/renderer/update';
|
2019-01-30 18:29:36 +01:00
|
|
|
import { renderActivity } from '../../remote/activitypub/renderer';
|
2019-11-09 10:51:54 +01:00
|
|
|
import { Users } from '../../models';
|
2019-04-07 14:50:36 +02:00
|
|
|
import { User } from '../../models/entities/user';
|
|
|
|
import { renderPerson } from '../../remote/activitypub/renderer/person';
|
2019-11-09 10:51:54 +01:00
|
|
|
import { deliverToFollowers } from '../../remote/activitypub/deliver-manager';
|
2020-05-10 11:42:31 +02:00
|
|
|
import { deliverToRelays } from '../relay';
|
2018-09-01 13:17:30 +02:00
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
export async function publishToFollowers(userId: User['id']) {
|
2019-04-12 18:43:22 +02:00
|
|
|
const user = await Users.findOne(userId);
|
2019-04-13 21:17:24 +02:00
|
|
|
if (user == null) throw new Error('user not found');
|
2018-09-01 13:17:30 +02:00
|
|
|
|
|
|
|
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーならUpdateを配信
|
2019-04-07 14:50:36 +02:00
|
|
|
if (Users.isLocalUser(user)) {
|
2019-11-09 10:51:54 +01:00
|
|
|
const content = renderActivity(renderUpdate(await renderPerson(user), user));
|
|
|
|
deliverToFollowers(user, content);
|
2020-05-10 11:42:31 +02:00
|
|
|
deliverToRelays(user, content);
|
2018-09-01 13:17:30 +02:00
|
|
|
}
|
|
|
|
}
|