blob: ba54c044752381e10ec7fb6e8b261f07ae1f57fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import { publishUserListStream } from '../stream';
import { User } from '../../models/entities/user';
import { UserList } from '../../models/entities/user-list';
import { UserListJoinings, Users } from '../../models';
import { UserListJoining } from '../../models/entities/user-list-joining';
import { genId } from '../../misc/gen-id';
import { fetchProxyAccount } from '../../misc/fetch-proxy-account';
import createFollowing from '../following/create';
export async function pushUserToUserList(target: User, list: UserList) {
await UserListJoinings.insert({
id: genId(),
createdAt: new Date(),
userId: target.id,
userListId: list.id
} as UserListJoining);
publishUserListStream(list.id, 'userAdded', await Users.pack(target));
// このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする
if (Users.isRemoteUser(target)) {
const proxy = await fetchProxyAccount();
if (proxy) {
createFollowing(proxy, target);
}
}
}
|