Merge branch 'develop' into feature/2024.10

This commit is contained in:
dakkar 2024-11-28 11:17:27 +00:00
commit eb25238a8e
257 changed files with 3053 additions and 68 deletions

View file

@ -10,6 +10,7 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js';
import type { UserProfilesRepository } from '@/models/_.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { DI } from '@/di-symbols.js';
import ms from 'ms';
export const meta = {
requireCredential: true,
@ -28,6 +29,12 @@ export const meta = {
},
},
},
limit: {
duration: ms('1hour'),
max: 10,
minInterval: ms('1sec'),
},
} as const;
export const paramDef = {

View file

@ -10,6 +10,7 @@ import type { UserProfilesRepository, UserSecurityKeysRepository } from '@/model
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { DI } from '@/di-symbols.js';
import { ApiError } from '../../../error.js';
import ms from 'ms';
export const meta = {
requireCredential: true,
@ -23,6 +24,12 @@ export const meta = {
id: 'f9c54d7f-d4c2-4d3c-9a8g-a70daac86512',
},
},
limit: {
duration: ms('1hour'),
max: 10,
minInterval: ms('1sec'),
},
} as const;
export const paramDef = {

View file

@ -11,6 +11,7 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { DI } from '@/di-symbols.js';
import { ApiError } from '../../../error.js';
import ms from 'ms';
export const meta = {
requireCredential: true,
@ -30,6 +31,12 @@ export const meta = {
id: '1fb7cb09-d46a-4fff-b8df-057708cce513',
},
},
limit: {
duration: ms('1hour'),
max: 10,
minInterval: ms('1sec'),
},
} as const;
export const paramDef = {

View file

@ -49,6 +49,12 @@ export const meta = {
},
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -48,6 +48,12 @@ export const meta = {
},
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -13,6 +13,12 @@ export const meta = {
requireCredential: true,
prohibitMoved: true,
kind: 'write:account',
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -26,6 +26,12 @@ export const meta = {
ref: 'NoteFavorite',
},
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -37,6 +37,12 @@ export const meta = {
},
},
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -26,6 +26,12 @@ export const meta = {
ref: 'GalleryPost',
},
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -36,6 +36,12 @@ export const meta = {
},
},
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -26,6 +26,12 @@ export const meta = {
ref: 'Page',
},
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -42,6 +42,12 @@ export const meta = {
optional: false, nullable: false,
ref: 'MeDetailed',
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -15,6 +15,12 @@ export const meta = {
requireCredential: true,
kind: 'write:account',
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -16,6 +16,12 @@ export const meta = {
errors: {
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -14,6 +14,12 @@ export const meta = {
res: {
type: 'object',
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -32,6 +32,12 @@ export const meta = {
},
},
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -22,6 +22,12 @@ export const meta = {
id: 'ac3ed68a-62f0-422b-a7bc-d5e09e8f6a6a',
},
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -22,7 +22,13 @@ export const meta = {
res: {
type: 'object',
}
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -17,6 +17,12 @@ export const meta = {
type: 'string',
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -17,6 +17,12 @@ export const meta = {
type: 'string',
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -21,6 +21,12 @@ export const meta = {
id: '1fac4e8a-a6cd-4e39-a4a5-3a7e11f1b019',
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -31,7 +31,13 @@ export const meta = {
},
},
},
}
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -10,6 +10,12 @@ import { RegistryApiService } from '@/core/RegistryApiService.js';
export const meta = {
requireCredential: true,
kind: 'write:account',
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -12,6 +12,12 @@ export const meta = {
requireCredential: true,
secure: true,
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -23,6 +23,12 @@ export const meta = {
ref: 'Signin',
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -29,6 +29,12 @@ export const meta = {
optional: false, nullable: false,
ref: 'MeDetailed',
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -571,7 +571,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
// フォロワーにUpdateを配信
this.accountUpdateService.publishToFollowers(user.id);
if (this.userNeedsPublishing(user, updates) || this.profileNeedsPublishing(profile, updatedProfile)) {
this.accountUpdateService.publishToFollowers(user.id);
}
const urls = updatedProfile.fields.filter(x => x.value.startsWith('https://'));
for (const url of urls) {
@ -613,4 +615,52 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
// なにもしない
}
}
// these two methods need to be kept in sync with
// `ApRendererService.renderPerson`
private userNeedsPublishing(oldUser: MiLocalUser, newUser: Partial<MiUser>): boolean {
for (const field of ['avatarId', 'bannerId', 'backgroundId', 'isBot', 'username', 'name', 'isLocked', 'isExplorable', 'isCat', 'noindex', 'speakAsCat', 'movedToUri', 'alsoKnownAs'] as (keyof MiUser)[]) {
if ((field in newUser) && oldUser[field] !== newUser[field]) {
return true;
}
}
for (const arrayField of ['emojis', 'tags'] as (keyof MiUser)[]) {
if ((arrayField in newUser) !== (arrayField in oldUser)) {
return true;
}
const oldArray = oldUser[arrayField] ?? [];
const newArray = newUser[arrayField] ?? [];
if (!Array.isArray(oldArray) || !Array.isArray(newArray)) {
return true;
}
if (oldArray.join("\0") !== newArray.join("\0")) {
return true;
}
}
return false;
}
private profileNeedsPublishing(oldProfile: MiUserProfile, newProfile: Partial<MiUserProfile>): boolean {
for (const field of ['description', 'followedMessage', 'birthday', 'location', 'listenbrainz'] as (keyof MiUserProfile)[]) {
if ((field in newProfile) && oldProfile[field] !== newProfile[field]) {
return true;
}
}
for (const arrayField of ['fields'] as (keyof MiUserProfile)[]) {
if ((arrayField in newProfile) !== (arrayField in oldProfile)) {
return true;
}
const oldArray = oldProfile[arrayField] ?? [];
const newArray = newProfile[arrayField] ?? [];
if (!Array.isArray(oldArray) || !Array.isArray(newArray)) {
return true;
}
if (oldArray.join("\0") !== newArray.join("\0")) {
return true;
}
}
return false;
}
}

View file

@ -55,6 +55,12 @@ export const meta = {
latestStatus: { type: 'integer', nullable: true },
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -24,6 +24,12 @@ export const meta = {
id: 'bae73e5a-5522-4965-ae19-3a8688e71d82',
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -46,6 +46,12 @@ export const meta = {
},
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {

View file

@ -52,6 +52,12 @@ export const meta = {
latestStatus: { type: 'integer', nullable: true },
},
},
// 10 calls per 5 seconds
limit: {
duration: 1000 * 5,
max: 10,
},
} as const;
export const paramDef = {

View file

@ -26,6 +26,11 @@ export const meta = {
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {