Skip to content

Commit

Permalink
Hide direct notes in user profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriha-chan committed Dec 2, 2023
1 parent d89a056 commit 1553345
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/backend/src/server/api/endpoints/users/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const paramDef = {
userId: { type: 'string', format: 'misskey:id' },
withReplies: { type: 'boolean', default: false },
withRenotes: { type: 'boolean', default: true },
withSpecified: { type: 'boolean', default: true },
withChannelNotes: { type: 'boolean', default: false },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sinceId: { type: 'string', format: 'misskey:id' },
Expand Down Expand Up @@ -86,6 +87,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withChannelNotes: ps.withChannelNotes,
withFiles: ps.withFiles,
withRenotes: ps.withRenotes,
withSpecified: ps.withSpecified
}, me);

return await this.noteEntityService.packMany(timeline, me);
Expand Down Expand Up @@ -122,7 +124,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}

if (note.channel?.isSensitive && !isSelf) return false;
if (note.visibility === 'specified' && (!me || (me.id !== note.userId && !note.visibleUserIds.some(v => v === me.id)))) return false;
if (note.visibility === 'specified' && (!ps.withSpecified || !me || (me.id !== note.userId && !note.visibleUserIds.some(v => v === me.id)))) return false;
if (note.visibility === 'followers' && !isFollowing && !isSelf) return false;

return true;
Expand All @@ -134,7 +136,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
userId: ps.userId,
withChannelNotes: ps.withChannelNotes,
withFiles: ps.withFiles,
withSpecified: ps.withSpecified,
withRenotes: ps.withRenotes,
withSpecified: ps.withSpecified,
}, me),
});

Expand All @@ -150,6 +154,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withChannelNotes: boolean,
withFiles: boolean,
withRenotes: boolean,
withSpecified: boolean,
}, me: MiLocalUser | null) {
const isSelf = me && (me.id === ps.userId);

Expand Down Expand Up @@ -181,6 +186,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
query.andWhere('note.fileIds != \'{}\'');
}

if (!ps.withSpecified) {
query.andWhere('note.visibility != \'specified\'');
}

if (ps.withRenotes === false) {
query.andWhere(new Brackets(qb => {
qb.orWhere('note.userId != :userId', { userId: ps.userId });
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/pages/user/index.timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const pagination = {
withRenotes: include.value === 'all',
withReplies: include.value === 'all',
withChannelNotes: include.value === 'all',
withSpecified: include.value === 'all',
withFiles: include.value === 'files',
})),
};
Expand Down

0 comments on commit 1553345

Please sign in to comment.