mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
check role assignments in featured timeline
This commit is contained in:
parent
f6eb3148f3
commit
76597d1a4c
1 changed files with 16 additions and 0 deletions
|
@ -12,6 +12,8 @@ import { FeaturedService } from '@/core/FeaturedService.js';
|
|||
import { isUserRelated } from '@/misc/is-user-related.js';
|
||||
import { CacheService } from '@/core/CacheService.js';
|
||||
import { QueryService } from '@/core/QueryService.js';
|
||||
import { ApiError } from '@/server/api/error.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['notes'],
|
||||
|
@ -30,6 +32,14 @@ export const meta = {
|
|||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
ltlDisabled: {
|
||||
message: 'Local timeline has been disabled.',
|
||||
code: 'LTL_DISABLED',
|
||||
id: '45a6eb02-7695-4393-b023-dd3be9aaaefd',
|
||||
},
|
||||
},
|
||||
|
||||
// Burst of 10 calls to handle tab reload, then 4/second for refresh
|
||||
limit: {
|
||||
type: 'bucket',
|
||||
|
@ -61,8 +71,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private noteEntityService: NoteEntityService,
|
||||
private featuredService: FeaturedService,
|
||||
private queryService: QueryService,
|
||||
private readonly roleService: RoleService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const policies = await this.roleService.getUserPolicies(me ? me.id : null);
|
||||
if (!policies.ltlAvailable) {
|
||||
throw new ApiError(meta.errors.ltlDisabled);
|
||||
}
|
||||
|
||||
let noteIds: string[];
|
||||
if (ps.channelId) {
|
||||
noteIds = await this.featuredService.getInChannelNotesRanking(ps.channelId, 50);
|
||||
|
|
Loading…
Add table
Reference in a new issue