AvatarDecoration federation
and more fix
This commit is contained in:
parent
a4974e3c8a
commit
085a93b9fc
9 changed files with 84 additions and 15 deletions
|
|
@ -88,7 +88,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
super(meta, paramDef, async (ps, me) => {
|
||||
const avatarDecorations = await this.avatarDecorationService.getAll(true);
|
||||
|
||||
return avatarDecorations.map(avatarDecoration => ({
|
||||
const filteredAvatarDecorations = avatarDecorations.filter(avatarDecoration => avatarDecoration.host === null);
|
||||
console.log(filteredAvatarDecorations);
|
||||
return filteredAvatarDecorations.map(avatarDecoration => ({
|
||||
id: avatarDecoration.id,
|
||||
createdAt: this.idService.parse(avatarDecoration.id).date.toISOString(),
|
||||
updatedAt: avatarDecoration.updatedAt?.toISOString() ?? null,
|
||||
|
|
|
|||
|
|
@ -70,7 +70,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
const decorations = await this.avatarDecorationService.getAll(true);
|
||||
const allRoles = await this.roleService.getRoles();
|
||||
|
||||
return decorations.map(decoration => ({
|
||||
// Filter decorations where host is null
|
||||
const filteredDecorations = decorations.filter(decoration => decoration.host === null);
|
||||
|
||||
return filteredDecorations.map(decoration => ({
|
||||
id: decoration.id,
|
||||
name: decoration.name,
|
||||
description: decoration.description,
|
||||
|
|
|
|||
|
|
@ -294,10 +294,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (typeof ps.preventAiLearning === 'boolean') profileUpdates.preventAiLearning = ps.preventAiLearning;
|
||||
if (typeof ps.isCat === 'boolean' && !ps.isGorilla) {
|
||||
updates.isCat = ps.isCat;
|
||||
};
|
||||
}
|
||||
if (typeof ps.isGorilla === 'boolean' && !ps.isCat) {
|
||||
updates.isGorilla = ps.isGorilla
|
||||
};
|
||||
updates.isGorilla = ps.isGorilla;
|
||||
}
|
||||
if (typeof ps.injectFeaturedNote === 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
|
||||
if (typeof ps.receiveAnnouncementEmail === 'boolean') profileUpdates.receiveAnnouncementEmail = ps.receiveAnnouncementEmail;
|
||||
if (typeof ps.alwaysMarkNsfw === 'boolean') {
|
||||
|
|
@ -342,11 +342,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
const [myRoles, myPolicies] = await Promise.all([this.roleService.getUserRoles(user.id), this.roleService.getUserPolicies(user.id)]);
|
||||
const allRoles = await this.roleService.getRoles();
|
||||
const decorationIds = decorations
|
||||
.filter(d => d.roleIdsThatCanBeUsedThisDecoration.filter(roleId => allRoles.some(r => r.id === roleId)).length === 0 || myRoles.some(r => d.roleIdsThatCanBeUsedThisDecoration.includes(r.id)))
|
||||
.filter(d => d.host === null && (d.roleIdsThatCanBeUsedThisDecoration.filter(roleId => allRoles.some(r => r.id === roleId)).length === 0 || myRoles.some(r => d.roleIdsThatCanBeUsedThisDecoration.includes(r.id))))
|
||||
.map(d => d.id);
|
||||
|
||||
if (ps.avatarDecorations.length > myPolicies.avatarDecorationLimit) throw new ApiError(meta.errors.restrictedByRole);
|
||||
|
||||
updates.avatarDecorations = ps.avatarDecorations.filter(d => decorationIds.includes(d.id)).map(d => ({
|
||||
id: d.id,
|
||||
angle: d.angle ?? 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue