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