summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-09-28 11:41:41 +0900
committerInsert5StarName <anime@shourai.de>2023-09-28 12:37:31 +0200
commit0e7a1ac44ece3de0d3f16a1835e9ddab513f9f6d (patch)
tree2f9af8b304f2b9dc0755069cc23e13f8b4bdf450 /packages/backend/src/server/api
parent.js (diff)
downloadsharkey-0e7a1ac44ece3de0d3f16a1835e9ddab513f9f6d.tar.gz
sharkey-0e7a1ac44ece3de0d3f16a1835e9ddab513f9f6d.tar.bz2
sharkey-0e7a1ac44ece3de0d3f16a1835e9ddab513f9f6d.zip
enhance: タイムラインからRenoteを除外するオプションを追加
Diffstat (limited to 'packages/backend/src/server/api')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts16
-rw-r--r--packages/backend/src/server/api/endpoints/users/notes.ts8
-rw-r--r--packages/backend/src/server/api/stream/channels/global-timeline.ts6
-rw-r--r--packages/backend/src/server/api/stream/channels/home-timeline.ts6
-rw-r--r--packages/backend/src/server/api/stream/channels/hybrid-timeline.ts6
-rw-r--r--packages/backend/src/server/api/stream/channels/local-timeline.ts6
6 files changed, 40 insertions, 8 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
index 6932073791..c20274b2ba 100644
--- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
@@ -49,6 +49,8 @@ export const paramDef = {
includeMyRenotes: { type: 'boolean', default: true },
includeRenotedMyNotes: { type: 'boolean', default: true },
includeLocalRenotes: { type: 'boolean', default: true },
+ withReplies: { type: 'boolean', default: false },
+ withRenotes: { type: 'boolean', default: true },
withFiles: {
type: 'boolean',
default: false,
@@ -130,6 +132,20 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}));
}
+ if (!ps.withReplies) {
+ query.andWhere('note.replyId IS NULL');
+ }
+
+ if (ps.withRenotes === false) {
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.renoteId IS NULL');
+ qb.orWhere(new Brackets(qb => {
+ qb.orWhere('note.text IS NOT NULL');
+ qb.orWhere('note.fileIds != \'{}\'');
+ }));
+ }));
+ }
+
if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');
}
diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts
index 982fcc858a..e660a0bb25 100644
--- a/packages/backend/src/server/api/endpoints/users/notes.ts
+++ b/packages/backend/src/server/api/endpoints/users/notes.ts
@@ -41,8 +41,8 @@ export const paramDef = {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
- includeReplies: { type: 'boolean', default: true },
- includeRenotes: { type: 'boolean', default: true },
+ withReplies: { type: 'boolean', default: false },
+ withRenotes: { type: 'boolean', default: true },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
@@ -115,11 +115,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}
- if (!ps.includeReplies) {
+ if (!ps.withReplies) {
query.andWhere('note.replyId IS NULL');
}
- if (ps.includeRenotes === false) {
+ if (ps.withRenotes === false) {
query.andWhere(new Brackets(qb => {
qb.orWhere('note.renoteId IS NULL');
qb.orWhere(new Brackets(qb => {
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 a33f1a956a..fef52b6856 100644
--- a/packages/backend/src/server/api/stream/channels/global-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts
@@ -19,6 +19,7 @@ class GlobalTimelineChannel extends Channel {
public static shouldShare = true;
public static requireCredential = false;
private withReplies: boolean;
+ private withRenotes: boolean;
constructor(
private metaService: MetaService,
@@ -37,7 +38,8 @@ class GlobalTimelineChannel extends Channel {
const policies = await this.roleService.getUserPolicies(this.user ? this.user.id : null);
if (!policies.gtlAvailable) return;
- this.withReplies = params.withReplies as boolean;
+ this.withReplies = params.withReplies ?? false;
+ this.withRenotes = params.withRenotes ?? true;
// Subscribe events
this.subscriber.on('notesStream', this.onNote);
@@ -68,6 +70,8 @@ class GlobalTimelineChannel extends Channel {
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
}
+ if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return;
+
// Ignore notes from instances the user has muted
if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? []))) return;
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 bd8888f679..198c68e1c2 100644
--- a/packages/backend/src/server/api/stream/channels/home-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts
@@ -17,6 +17,7 @@ class HomeTimelineChannel extends Channel {
public static shouldShare = true;
public static requireCredential = true;
private withReplies: boolean;
+ private withRenotes: boolean;
constructor(
private noteEntityService: NoteEntityService,
@@ -30,7 +31,8 @@ class HomeTimelineChannel extends Channel {
@bindThis
public async init(params: any) {
- this.withReplies = params.withReplies as boolean;
+ this.withReplies = params.withReplies ?? false;
+ this.withRenotes = params.withRenotes ?? true;
this.subscriber.on('notesStream', this.onNote);
}
@@ -77,6 +79,8 @@ class HomeTimelineChannel extends Channel {
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
}
+ if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return;
+
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
// 流れてきた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 760fb8d19f..cde4297478 100644
--- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
@@ -19,6 +19,7 @@ class HybridTimelineChannel extends Channel {
public static shouldShare = true;
public static requireCredential = true;
private withReplies: boolean;
+ private withRenotes: boolean;
constructor(
private metaService: MetaService,
@@ -37,7 +38,8 @@ class HybridTimelineChannel extends Channel {
const policies = await this.roleService.getUserPolicies(this.user ? this.user.id : null);
if (!policies.ltlAvailable) return;
- this.withReplies = params.withReplies as boolean;
+ this.withReplies = params.withReplies ?? false;
+ this.withRenotes = params.withRenotes ?? true;
// Subscribe events
this.subscriber.on('notesStream', this.onNote);
@@ -89,6 +91,8 @@ class HybridTimelineChannel extends Channel {
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
}
+ if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return;
+
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
// 流れてきた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 f32f8c5cec..ef708c4fee 100644
--- a/packages/backend/src/server/api/stream/channels/local-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts
@@ -18,6 +18,7 @@ class LocalTimelineChannel extends Channel {
public static shouldShare = true;
public static requireCredential = false;
private withReplies: boolean;
+ private withRenotes: boolean;
constructor(
private metaService: MetaService,
@@ -36,7 +37,8 @@ class LocalTimelineChannel extends Channel {
const policies = await this.roleService.getUserPolicies(this.user ? this.user.id : null);
if (!policies.ltlAvailable) return;
- this.withReplies = params.withReplies as boolean;
+ this.withReplies = params.withReplies ?? false;
+ this.withRenotes = params.withRenotes ?? true;
// Subscribe events
this.subscriber.on('notesStream', this.onNote);
@@ -68,6 +70,8 @@ class LocalTimelineChannel extends Channel {
if (reply.userId !== this.user.id && note.userId !== this.user.id && reply.userId !== note.userId) return;
}
+ if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return;
+
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する