mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
merge: Fix bubble timeline logic (!1088)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1088 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
f06ca9f7ee
3 changed files with 21 additions and 4 deletions
|
@ -81,7 +81,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||
.andWhere('note.visibility = \'public\'')
|
||||
.andWhere('note.channelId IS NULL')
|
||||
.andWhere('note.userHost IS NULL')
|
||||
.andWhere('note.userHost IS NOT NULL')
|
||||
.andWhere('userInstance.isBubbled = true') // This comes from generateBlockedHostQueryForNote below
|
||||
.innerJoinAndSelect('note.user', 'user')
|
||||
.leftJoinAndSelect('note.reply', 'reply')
|
||||
|
@ -94,6 +94,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||
if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
||||
if (!me) query.andWhere('user.requireSigninToViewContents = false');
|
||||
|
||||
if (ps.withFiles) {
|
||||
query.andWhere('note.fileIds != \'{}\'');
|
||||
|
@ -115,7 +116,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
let timeline = await query.limit(ps.limit).getMany();
|
||||
|
||||
timeline = timeline.filter(note => {
|
||||
if (note.user?.isSilenced && me && followings && note.userId !== me.id && !followings[note.userId]) return false;
|
||||
if (note.user?.isSilenced) {
|
||||
if (!me) return false;
|
||||
if (!followings) return false;
|
||||
if (note.userId !== me.id) {
|
||||
return followings[note.userId];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
|
@ -65,6 +65,9 @@ export default abstract class Channel {
|
|||
* ミュートとブロックされてるを処理する
|
||||
*/
|
||||
protected isNoteMutedOrBlocked(note: Packed<'Note'>): boolean {
|
||||
// Ignore notes that require sign-in
|
||||
if (note.user.requireSigninToViewContents && !this.user) return true;
|
||||
|
||||
// 流れてきたNoteがインスタンスミュートしたインスタンスが関わる
|
||||
if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? [])) && !this.following[note.userId]) return true;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import { RoleService } from '@/core/RoleService.js';
|
|||
import type { MiMeta } from '@/models/Meta.js';
|
||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||
import type { JsonObject } from '@/misc/json-value.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import Channel, { MiChannelService } from '../channel.js';
|
||||
|
||||
class BubbleTimelineChannel extends Channel {
|
||||
|
@ -26,6 +27,7 @@ class BubbleTimelineChannel extends Channel {
|
|||
constructor(
|
||||
private metaService: MetaService,
|
||||
private roleService: RoleService,
|
||||
private readonly utilityService: UtilityService,
|
||||
noteEntityService: NoteEntityService,
|
||||
|
||||
id: string,
|
||||
|
@ -56,12 +58,15 @@ class BubbleTimelineChannel extends Channel {
|
|||
if (note.visibility !== 'public') return;
|
||||
if (note.channelId != null) return;
|
||||
if (note.user.host == null) return;
|
||||
if (!this.instance.bubbleInstances.includes(note.user.host)) return;
|
||||
if (!this.utilityService.isBubbledHost(note.user.host)) return;
|
||||
if (note.user.requireSigninToViewContents && this.user == null) return;
|
||||
|
||||
if (isRenotePacked(note) && !isQuotePacked(note) && !this.withRenotes) return;
|
||||
|
||||
if (note.user.isSilenced && !this.following[note.userId] && note.userId !== this.user!.id) return;
|
||||
if (note.user.isSilenced) {
|
||||
if (!this.user) return;
|
||||
if (note.userId !== this.user.id && !this.following[note.userId]) return;
|
||||
}
|
||||
|
||||
if (this.isNoteMutedOrBlocked(note)) return;
|
||||
|
||||
|
@ -88,6 +93,7 @@ export class BubbleTimelineChannelService implements MiChannelService<false> {
|
|||
private metaService: MetaService,
|
||||
private roleService: RoleService,
|
||||
private noteEntityService: NoteEntityService,
|
||||
private readonly utilityService: UtilityService,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -96,6 +102,7 @@ export class BubbleTimelineChannelService implements MiChannelService<false> {
|
|||
return new BubbleTimelineChannel(
|
||||
this.metaService,
|
||||
this.roleService,
|
||||
this.utilityService,
|
||||
this.noteEntityService,
|
||||
id,
|
||||
connection,
|
||||
|
|
Loading…
Add table
Reference in a new issue