+
(この投稿は非公開です)
%fa:reply%
RP: ...
diff --git a/src/models/note.ts b/src/models/note.ts
index 918ef6d69e..3256a8c153 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -163,9 +163,9 @@ export const pack = async (
detail: boolean
}
) => {
- const opts = options || {
- detail: true,
- };
+ const opts = Object.assign({
+ detail: true
+ }, options);
// Me
const meId: mongo.ObjectID = me
@@ -208,7 +208,7 @@ export const pack = async (
hide = false;
} else {
// 指定されているかどうか
- const specified = _note.visibleUserIds.test(id => id.equals(meId));
+ const specified = _note.visibleUserIds.some(id => id.equals(meId));
if (specified) {
hide = false;
@@ -245,6 +245,9 @@ export const pack = async (
_note.id = _note._id;
delete _note._id;
+ delete _note._user;
+ delete _note._reply;
+ delete _note.repost;
delete _note.mentions;
if (_note.geo) delete _note.geo.type;
@@ -262,11 +265,9 @@ export const pack = async (
}
// Populate media
- if (_note.mediaIds && !hide) {
- _note.media = Promise.all(_note.mediaIds.map(fileId =>
- packFile(fileId)
- ));
- }
+ _note.media = hide ? [] : Promise.all(_note.mediaIds.map(fileId =>
+ packFile(fileId)
+ ));
// When requested a detailed note data
if (opts.detail) {
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);
-
- // Publish note to local timeline stream
- publishLocalTimelineStream(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 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;
- }
+ if (note.visibility == 'specified') {
+ data.visibleUsers.forEach(async u => {
+ stream(u._id, 'note', await pack(note, u, {
+ detail: true
+ }));
+ });
+ }
- // Publish event to followers stream
- stream(following.followerId, 'note', noteObj);
- } else {
- //#region AP配送
- // フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信
- if (isLocalUser(user)) {
- deliver(user, await render(), follower.inbox);
+ 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
}
- //#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))
--
cgit v1.2.3-freya
From c32c3c137028e32695a5464b7a7fc9faa3f13d96 Mon Sep 17 00:00:00 2001
From: syuilo
Date: Sun, 6 May 2018 01:46:35 +0900
Subject: Fix bug
---
src/models/note.ts | 4 ++--
src/server/web/views/note.pug | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
(limited to 'src/models/note.ts')
diff --git a/src/models/note.ts b/src/models/note.ts
index 3256a8c153..b2b93453e6 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -286,7 +286,7 @@ export const pack = async (
_id: -1
}
});
- return prev ? prev._id : null;
+ return prev ? prev._id.toHexString() : null;
})();
// Get next note info
@@ -304,7 +304,7 @@ export const pack = async (
_id: 1
}
});
- return next ? next._id : null;
+ return next ? next._id.toHexString() : null;
})();
if (_note.replyId) {
diff --git a/src/server/web/views/note.pug b/src/server/web/views/note.pug
index 8cb1d954da..bc8dcdab8f 100644
--- a/src/server/web/views/note.pug
+++ b/src/server/web/views/note.pug
@@ -21,6 +21,6 @@ block meta
meta(property='og:image' content= img)
if note.prev
- link(rel='prev' href=`${config.url}/notes/${note.prev.id}`)
+ link(rel='prev' href=`${config.url}/notes/${note.prev}`)
if note.next
- link(rel='next' href=`${config.url}/notes/${note.next.id}`)
+ link(rel='next' href=`${config.url}/notes/${note.next}`)
--
cgit v1.2.3-freya
From 9f4624283dbaf0ed9bde8ee8ac6db287dbba15ed Mon Sep 17 00:00:00 2001
From: syuilo
Date: Mon, 14 May 2018 09:01:37 +0900
Subject: Disable prev/next
---
src/models/note.ts | 39 ++++-----------------------------------
1 file changed, 4 insertions(+), 35 deletions(-)
(limited to 'src/models/note.ts')
diff --git a/src/models/note.ts b/src/models/note.ts
index b2b93453e6..337711bcfa 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -271,41 +271,10 @@ export const pack = async (
// When requested a detailed note data
if (opts.detail) {
- // Get previous note info
- _note.prev = (async () => {
- const prev = await Note.findOne({
- userId: _note.userId,
- _id: {
- $lt: id
- }
- }, {
- fields: {
- _id: true
- },
- sort: {
- _id: -1
- }
- });
- return prev ? prev._id.toHexString() : null;
- })();
-
- // Get next note info
- _note.next = (async () => {
- const next = await Note.findOne({
- userId: _note.userId,
- _id: {
- $gt: id
- }
- }, {
- fields: {
- _id: true
- },
- sort: {
- _id: 1
- }
- });
- return next ? next._id.toHexString() : null;
- })();
+ //#region 重いので廃止
+ _note.prev = null;
+ _note.next = null;
+ //#endregion
if (_note.replyId) {
// Populate reply to note
--
cgit v1.2.3-freya
From 06461bb9ee6d579fceaaa700ed0b4167f3e00058 Mon Sep 17 00:00:00 2001
From: syuilo
Date: Mon, 14 May 2018 09:15:43 +0900
Subject: NoteのuserIdに対してインデックスを張るように
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/models/note.ts | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'src/models/note.ts')
diff --git a/src/models/note.ts b/src/models/note.ts
index 337711bcfa..f42bb2a49d 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -15,9 +15,8 @@ import Notification, { deleteNotification } from './notification';
import Following from './following';
const Note = db.get('notes');
-
Note.createIndex('uri', { sparse: true, unique: true });
-
+Note.createIndex('userId');
export default Note;
export function isValidText(text: string): boolean {
--
cgit v1.2.3-freya