summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-07-21 07:05:51 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-07-21 07:05:51 +0900
commit91ad9e4c41668ef34b49c331e9476f9d13f55a70 (patch)
tree8f0f7167679f63fa9d15dcb0758da4e19d12acc1 /src
parentwip (diff)
downloadsharkey-91ad9e4c41668ef34b49c331e9476f9d13f55a70.tar.gz
sharkey-91ad9e4c41668ef34b49c331e9476f9d13f55a70.tar.bz2
sharkey-91ad9e4c41668ef34b49c331e9476f9d13f55a70.zip
wip
Diffstat (limited to 'src')
-rw-r--r--src/services/note/create.ts42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index ab53252cf5..3a95328f3a 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -112,6 +112,10 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
saveReply(data.reply, note);
}
+ if (data.renote) {
+ incRenoteCount(data.renote);
+ }
+
if (isQuote(note)) {
saveQuote(data.renote, note);
}
@@ -119,25 +123,16 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
// Pack the note
const noteObj = await pack(note);
- const noteActivity = await (async () => {
- const content = data.renote && data.text == null
- ? renderAnnounce(data.renote.uri ? data.renote.uri : await renderNote(data.renote))
- : renderCreate(await renderNote(note));
- return packAp(content);
- })();
-
const nm = new NotificationManager(user, note);
createMentionedEvents(mentionedUsers, noteObj, nm);
+ const noteActivity = await renderActivity(data, note);
+
if (isLocalUser(user)) {
deliverNoteToMentionedRemoteUsers(mentionedUsers, user, noteActivity);
}
- if (!silent) {
- publish(user, note, noteObj, data.reply, data.renote, data.visibleUsers, noteActivity);
- }
-
// If has in reply to note
if (data.reply) {
// Fetch watchers
@@ -176,19 +171,32 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
event(data.renote.userId, 'renote', noteObj);
}
}
+ }
- // Update renoteee status
- Note.update({ _id: data.renote._id }, {
- $inc: {
- renoteCount: 1
- }
- });
+ if (!silent) {
+ publish(user, note, noteObj, data.reply, data.renote, data.visibleUsers, noteActivity);
}
// Register to search database
index(note);
});
+async function renderActivity(data: Option, note: INote) {
+ const content = data.renote && data.text == null
+ ? renderAnnounce(data.renote.uri ? data.renote.uri : await renderNote(data.renote))
+ : renderCreate(await renderNote(note));
+
+ return packAp(content);
+}
+
+function incRenoteCount(renote: INote) {
+ Note.update({ _id: renote._id }, {
+ $inc: {
+ renoteCount: 1
+ }
+ });
+}
+
async function publish(user: IUser, note: INote, noteObj: any, reply: INote, renote: INote, visibleUsers: IUser[], noteActivity: any) {
if (isLocalUser(user)) {
// 投稿がリプライかつ投稿者がローカルユーザーかつリプライ先の投稿の投稿者がリモートユーザーなら配送