2021-08-19 07:55:45 -05: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 06:17:30 -05:00
|
|
|
|
2019-04-07 07:50:36 -05:00
|
|
|
export async function publishToFollowers(userId: User['id']) {
|
2019-04-12 11:43:22 -05:00
|
|
|
const user = await Users.findOne(userId);
|
2019-04-13 14:17:24 -05:00
|
|
|
if (user == null) throw new Error('user not found');
|
2018-09-01 06:17:30 -05:00
|
|
|
|
|
|
|
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーならUpdateを配信
|
2019-04-07 07:50:36 -05:00
|
|
|
if (Users.isLocalUser(user)) {
|
2019-11-09 03:51:54 -06:00
|
|
|
const content = renderActivity(renderUpdate(await renderPerson(user), user));
|
|
|
|
deliverToFollowers(user, content);
|
2020-05-10 04:42:31 -05:00
|
|
|
deliverToRelays(user, content);
|
2018-09-01 06:17:30 -05:00
|
|
|
}
|
|
|
|
}
|