summaryrefslogtreecommitdiff
path: root/src/services/note
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-29 07:01:47 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-29 07:01:47 +0900
commite9940c92214f4b70b6f8dfdf1f4dd7ce1814e67d (patch)
tree19e207c8231fd8e0f7c44ee8632c19ebf5db8d26 /src/services/note
parentwip (diff)
downloadsharkey-e9940c92214f4b70b6f8dfdf1f4dd7ce1814e67d.tar.gz
sharkey-e9940c92214f4b70b6f8dfdf1f4dd7ce1814e67d.tar.bz2
sharkey-e9940c92214f4b70b6f8dfdf1f4dd7ce1814e67d.zip
wip
Diffstat (limited to 'src/services/note')
-rw-r--r--src/services/note/create.ts71
1 files changed, 44 insertions, 27 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index 2b9fb0b1d8..8d66267132 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -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 (note.visibility == 'specified') {
+ data.visibleUsers.forEach(async u => {
+ stream(u._id, 'note', await pack(note, u, {
+ detail: true
+ }));
+ });
+ }
- if (isLocalUser(follower)) {
- // ストーキングしていない場合
- if (!following.stalk) {
- // この投稿が返信ならスキップ
- if (note.replyId && !note._reply.userId.equals(following.followerId) && !note._reply.userId.equals(note.userId)) return;
- }
+ 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;
- // Publish event to followers stream
- stream(following.followerId, 'note', noteObj);
- } else {
- //#region AP配送
- // フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信
- if (isLocalUser(user)) {
- deliver(user, await render(), follower.inbox);
+ 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
}
- //#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))