2021-08-19 14:55:45 +02:00
|
|
|
import renderUpdate from '@/remote/activitypub/renderer/update';
|
|
|
|
import { renderActivity } from '@/remote/activitypub/renderer/index';
|
|
|
|
import { Users } from '@/models/index';
|
|
|
|
import { User } from '@/models/entities/user';
|
|
|
|
import { renderPerson } from '@/remote/activitypub/renderer/person';
|
|
|
|
import { deliverToFollowers } from '@/remote/activitypub/deliver-manager';
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|