wip
This commit is contained in:
parent
7797a0746a
commit
e9940c9221
7 changed files with 63 additions and 43 deletions
|
@ -123,42 +123,59 @@ export default async (user: IUser, data: {
|
|||
if (note.channelId == null) {
|
||||
if (!silent) {
|
||||
if (isLocalUser(user)) {
|
||||
// Publish event to myself's stream
|
||||
stream(note.userId, 'note', noteObj);
|
||||
if (note.visibility == 'private') {
|
||||
// Publish event to myself's stream
|
||||
stream(note.userId, 'note', await pack(note, user, {
|
||||
detail: true
|
||||
}));
|
||||
} else {
|
||||
// Publish event to myself's stream
|
||||
stream(note.userId, 'note', noteObj);
|
||||
|
||||
// Publish note to local timeline stream
|
||||
publishLocalTimelineStream(noteObj);
|
||||
// Publish note to local timeline stream
|
||||
publishLocalTimelineStream(noteObj);
|
||||
}
|
||||
}
|
||||
|
||||
// Publish note to global timeline stream
|
||||
publishGlobalTimelineStream(noteObj);
|
||||
|
||||
// フォロワーに配信
|
||||
Following.find({
|
||||
followeeId: note.userId
|
||||
}).then(followers => {
|
||||
followers.map(async following => {
|
||||
const follower = following._follower;
|
||||
|
||||
if (isLocalUser(follower)) {
|
||||
// ストーキングしていない場合
|
||||
if (!following.stalk) {
|
||||
// この投稿が返信ならスキップ
|
||||
if (note.replyId && !note._reply.userId.equals(following.followerId) && !note._reply.userId.equals(note.userId)) return;
|
||||
}
|
||||
|
||||
// Publish event to followers stream
|
||||
stream(following.followerId, 'note', noteObj);
|
||||
} else {
|
||||
//#region AP配送
|
||||
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信
|
||||
if (isLocalUser(user)) {
|
||||
deliver(user, await render(), follower.inbox);
|
||||
}
|
||||
//#endergion
|
||||
}
|
||||
if (note.visibility == 'specified') {
|
||||
data.visibleUsers.forEach(async u => {
|
||||
stream(u._id, 'note', await pack(note, u, {
|
||||
detail: true
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (note.visibility == 'public' || note.visibility == 'home' || note.visibility == 'followers') {
|
||||
// フォロワーに配信
|
||||
Following.find({
|
||||
followeeId: note.userId
|
||||
}).then(followers => {
|
||||
followers.map(async following => {
|
||||
const follower = following._follower;
|
||||
|
||||
if (isLocalUser(follower)) {
|
||||
// ストーキングしていない場合
|
||||
if (!following.stalk) {
|
||||
// この投稿が返信ならスキップ
|
||||
if (note.replyId && !note._reply.userId.equals(following.followerId) && !note._reply.userId.equals(note.userId)) return;
|
||||
}
|
||||
|
||||
// Publish event to followers stream
|
||||
stream(following.followerId, 'note', noteObj);
|
||||
} else {
|
||||
//#region AP配送
|
||||
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信
|
||||
if (isLocalUser(user)) {
|
||||
deliver(user, await render(), follower.inbox);
|
||||
}
|
||||
//#endergion
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// リストに配信
|
||||
UserList.find({
|
||||
|
@ -170,7 +187,7 @@ export default async (user: IUser, data: {
|
|||
});
|
||||
}
|
||||
|
||||
//#region AP配送
|
||||
//#region リプライとAnnounceのAP配送
|
||||
const render = async () => {
|
||||
const content = data.renote && data.text == null
|
||||
? renderAnnounce(data.renote.uri ? data.renote.uri : await renderNote(data.renote))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue