summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api
diff options
context:
space:
mode:
authorMar0xy <marie@kaifa.ch>2023-10-15 23:36:38 +0200
committerMar0xy <marie@kaifa.ch>2023-10-15 23:36:38 +0200
commitca428977a58e3ac1fe1695d7e283bd3d1d258f25 (patch)
tree15b21a2e89c72722b67b754e8dcce54bfb859507 /packages/backend/src/server/api
parentMerge branch 'develop' of https://github.com/transfem-org/Sharkey into develop (diff)
parentUpdate CHANGELOG.md (diff)
downloadsharkey-ca428977a58e3ac1fe1695d7e283bd3d1d258f25.tar.gz
sharkey-ca428977a58e3ac1fe1695d7e283bd3d1d258f25.tar.bz2
sharkey-ca428977a58e3ac1fe1695d7e283bd3d1d258f25.zip
merge: upstream
Diffstat (limited to 'packages/backend/src/server/api')
-rw-r--r--packages/backend/src/server/api/stream/channels/channel.ts18
-rw-r--r--packages/backend/src/server/api/stream/channels/global-timeline.ts18
-rw-r--r--packages/backend/src/server/api/stream/channels/hashtag.ts12
-rw-r--r--packages/backend/src/server/api/stream/channels/home-timeline.ts30
-rw-r--r--packages/backend/src/server/api/stream/channels/hybrid-timeline.ts30
-rw-r--r--packages/backend/src/server/api/stream/channels/local-timeline.ts18
-rw-r--r--packages/backend/src/server/api/stream/channels/user-list.ts32
7 files changed, 49 insertions, 109 deletions
diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts
index a01714e76d..e4c34e00ce 100644
--- a/packages/backend/src/server/api/stream/channels/channel.ts
+++ b/packages/backend/src/server/api/stream/channels/channel.ts
@@ -38,19 +38,6 @@ class ChannelChannel extends Channel {
private async onNote(note: Packed<'Note'>) {
if (note.channelId !== this.channelId) return;
- // リプライなら再pack
- if (note.replyId != null) {
- note.reply = await this.noteEntityService.pack(note.replyId, this.user, {
- detail: true,
- });
- }
- // Renoteなら再pack
- if (note.renoteId != null) {
- note.renote = await this.noteEntityService.pack(note.renoteId, this.user, {
- detail: true,
- });
- }
-
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
@@ -58,6 +45,11 @@ class ChannelChannel extends Channel {
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
+ if (this.user && note.renoteId && !note.text) {
+ const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renoteId, this.user.id);
+ note.renote!.myReaction = myRenoteReaction;
+ }
+
this.connection.cacheNote(note);
this.send('note', note);
diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts
index 03f2dff62b..c499d1787e 100644
--- a/packages/backend/src/server/api/stream/channels/global-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts
@@ -52,19 +52,6 @@ class GlobalTimelineChannel extends Channel {
if (note.visibility !== 'public') return;
if (note.channelId != null) return;
- // リプライなら再pack
- if (note.replyId != null) {
- note.reply = await this.noteEntityService.pack(note.replyId, this.user, {
- detail: true,
- });
- }
- // Renoteなら再pack
- if (note.renoteId != null) {
- note.renote = await this.noteEntityService.pack(note.renoteId, this.user, {
- detail: true,
- });
- }
-
// 関係ない返信は除外
if (note.reply && !this.following[note.userId]?.withReplies) {
const reply = note.reply;
@@ -84,6 +71,11 @@ class GlobalTimelineChannel extends Channel {
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
+ if (this.user && note.renoteId && !note.text) {
+ const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renoteId, this.user.id);
+ note.renote!.myReaction = myRenoteReaction;
+ }
+
this.connection.cacheNote(note);
this.send('note', note);
diff --git a/packages/backend/src/server/api/stream/channels/hashtag.ts b/packages/backend/src/server/api/stream/channels/hashtag.ts
index 3945b1a1eb..2cfe9572d3 100644
--- a/packages/backend/src/server/api/stream/channels/hashtag.ts
+++ b/packages/backend/src/server/api/stream/channels/hashtag.ts
@@ -43,13 +43,6 @@ class HashtagChannel extends Channel {
const matched = this.q.some(tags => tags.every(tag => noteTags.includes(normalizeForSearch(tag))));
if (!matched) return;
- // Renoteなら再pack
- if (note.renoteId != null) {
- note.renote = await this.noteEntityService.pack(note.renoteId, this.user, {
- detail: true,
- });
- }
-
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
@@ -57,6 +50,11 @@ class HashtagChannel extends Channel {
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
+ if (this.user && note.renoteId && !note.text) {
+ const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renoteId, this.user.id);
+ note.renote!.myReaction = myRenoteReaction;
+ }
+
this.connection.cacheNote(note);
this.send('note', note);
diff --git a/packages/backend/src/server/api/stream/channels/home-timeline.ts b/packages/backend/src/server/api/stream/channels/home-timeline.ts
index 24be590504..de755cccb9 100644
--- a/packages/backend/src/server/api/stream/channels/home-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts
@@ -51,27 +51,10 @@ class HomeTimelineChannel extends Channel {
// Ignore notes from instances the user has muted
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances ?? []))) return;
- if (['followers', 'specified'].includes(note.visibility)) {
- note = await this.noteEntityService.pack(note.id, this.user!, {
- detail: true,
- });
-
- if (note.isHidden) {
- return;
- }
- } else {
- // リプライなら再pack
- if (note.replyId != null) {
- note.reply = await this.noteEntityService.pack(note.replyId, this.user!, {
- detail: true,
- });
- }
- // Renoteなら再pack
- if (note.renoteId != null) {
- note.renote = await this.noteEntityService.pack(note.renoteId, this.user!, {
- detail: true,
- });
- }
+ if (note.visibility === 'followers') {
+ if (!Object.hasOwn(this.following, note.userId)) return;
+ } else if (note.visibility === 'specified') {
+ if (!note.visibleUserIds!.includes(this.user!.id)) return;
}
// 関係ない返信は除外
@@ -90,6 +73,11 @@ class HomeTimelineChannel extends Channel {
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
+ if (this.user && note.renoteId && !note.text) {
+ const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renoteId, this.user.id);
+ note.renote!.myReaction = myRenoteReaction;
+ }
+
this.connection.cacheNote(note);
this.send('note', note);
diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
index adedca5152..83f0bccd90 100644
--- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
@@ -62,27 +62,10 @@ class HybridTimelineChannel extends Channel {
(note.channelId != null && this.followingChannels.has(note.channelId))
)) return;
- if (['followers', 'specified'].includes(note.visibility)) {
- note = await this.noteEntityService.pack(note.id, this.user!, {
- detail: true,
- });
-
- if (note.isHidden) {
- return;
- }
- } else {
- // リプライなら再pack
- if (note.replyId != null) {
- note.reply = await this.noteEntityService.pack(note.replyId, this.user!, {
- detail: true,
- });
- }
- // Renoteなら再pack
- if (note.renoteId != null) {
- note.renote = await this.noteEntityService.pack(note.renoteId, this.user!, {
- detail: true,
- });
- }
+ if (note.visibility === 'followers') {
+ if (!Object.hasOwn(this.following, note.userId)) return;
+ } else if (note.visibility === 'specified') {
+ if (!note.visibleUserIds!.includes(this.user!.id)) return;
}
// Ignore notes from instances the user has muted
@@ -104,6 +87,11 @@ class HybridTimelineChannel extends Channel {
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
+ if (this.user && note.renoteId && !note.text) {
+ const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renoteId, this.user.id);
+ note.renote!.myReaction = myRenoteReaction;
+ }
+
this.connection.cacheNote(note);
this.send('note', note);
diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts
index 69aa366f00..a211041134 100644
--- a/packages/backend/src/server/api/stream/channels/local-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts
@@ -54,19 +54,6 @@ class LocalTimelineChannel extends Channel {
if (note.visibility !== 'public') return;
if (note.channelId != null && !this.followingChannels.has(note.channelId)) return;
- // リプライなら再pack
- if (note.replyId != null) {
- note.reply = await this.noteEntityService.pack(note.replyId, this.user, {
- detail: true,
- });
- }
- // Renoteなら再pack
- if (note.renoteId != null) {
- note.renote = await this.noteEntityService.pack(note.renoteId, this.user, {
- detail: true,
- });
- }
-
// 関係ない返信は除外
if (note.reply && this.user && !this.following[note.userId]?.withReplies && !this.withReplies) {
const reply = note.reply;
@@ -83,6 +70,11 @@ class LocalTimelineChannel extends Channel {
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
+ if (this.user && note.renoteId && !note.text) {
+ const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renoteId, this.user.id);
+ note.renote!.myReaction = myRenoteReaction;
+ }
+
this.connection.cacheNote(note);
this.send('note', note);
diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts
index 240822d9ab..b73cedaa8b 100644
--- a/packages/backend/src/server/api/stream/channels/user-list.ts
+++ b/packages/backend/src/server/api/stream/channels/user-list.ts
@@ -82,27 +82,10 @@ class UserListChannel extends Channel {
if (!Object.hasOwn(this.membershipsMap, note.userId)) return;
- if (['followers', 'specified'].includes(note.visibility)) {
- note = await this.noteEntityService.pack(note.id, this.user, {
- detail: true,
- });
-
- if (note.isHidden) {
- return;
- }
- } else {
- // リプライなら再pack
- if (note.replyId != null) {
- note.reply = await this.noteEntityService.pack(note.replyId, this.user, {
- detail: true,
- });
- }
- // Renoteなら再pack
- if (note.renoteId != null) {
- note.renote = await this.noteEntityService.pack(note.renoteId, this.user, {
- detail: true,
- });
- }
+ if (note.visibility === 'followers') {
+ if (!Object.hasOwn(this.following, note.userId)) return;
+ } else if (note.visibility === 'specified') {
+ if (!note.visibleUserIds!.includes(this.user!.id)) return;
}
// 関係ない返信は除外
@@ -119,6 +102,13 @@ class UserListChannel extends Channel {
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
+ if (this.user && note.renoteId && !note.text) {
+ const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renoteId, this.user.id);
+ note.renote!.myReaction = myRenoteReaction;
+ }
+
+ this.connection.cacheNote(note);
+
this.send('note', note);
}