mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
replace silenced users check with generateSilencedUserQueryForNotes in bubble-timeline.ts
This commit is contained in:
parent
15ebb0ef85
commit
2258e439af
1 changed files with 2 additions and 18 deletions
|
@ -68,7 +68,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
private queryService: QueryService,
|
private queryService: QueryService,
|
||||||
private roleService: RoleService,
|
private roleService: RoleService,
|
||||||
private activeUsersChart: ActiveUsersChart,
|
private activeUsersChart: ActiveUsersChart,
|
||||||
private cacheService: CacheService,
|
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const policies = await this.roleService.getUserPolicies(me ? me.id : null);
|
const policies = await this.roleService.getUserPolicies(me ? me.id : null);
|
||||||
|
@ -76,10 +75,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
throw new ApiError(meta.errors.btlDisabled);
|
throw new ApiError(meta.errors.btlDisabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run this asynchronously - we will await it after the query completes.
|
|
||||||
// Catch-suppression is needed to avoid "unhandled rejection" if the query throws.
|
|
||||||
const followingsPromise = me ? this.cacheService.userFollowingsCache.fetch(me.id).catch(() => null) : null;
|
|
||||||
|
|
||||||
//#region Construct query
|
//#region Construct query
|
||||||
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'),
|
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'),
|
||||||
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||||
|
@ -92,6 +87,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
this.queryService.generateBlockedHostQueryForNote(query);
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
|
this.queryService.generateSilencedUserQueryForNotes(query, me);
|
||||||
if (me) {
|
if (me) {
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
@ -122,19 +118,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
let timeline = await query.limit(ps.limit).getMany();
|
const timeline = await query.limit(ps.limit).getMany();
|
||||||
|
|
||||||
const followings = await followingsPromise;
|
|
||||||
if (me && followings) {
|
|
||||||
timeline = timeline.filter(note => {
|
|
||||||
// Allow my own notes
|
|
||||||
if (note.userId === me.id) return true;
|
|
||||||
// Allow if not silenced
|
|
||||||
if (!note.user?.isSilenced) return true;
|
|
||||||
// Allow if following
|
|
||||||
return followings[note.userId];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (me) {
|
if (me) {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue