upd: port Listenbrainz
This commit is contained in:
parent
57c37a8938
commit
113a67077e
9 changed files with 210 additions and 3 deletions
20
packages/backend/migration/1691264431000-add-lb-to-user.js
Normal file
20
packages/backend/migration/1691264431000-add-lb-to-user.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
export class AddLbToUser1691264431000 {
|
||||
name = "AddLbToUser1691264431000";
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "user_profile"
|
||||
ADD "listenbrainz" character varying(128) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
COMMENT ON COLUMN "user_profile"."listenbrainz"
|
||||
IS 'listenbrainz username to fetch currently playing.'
|
||||
`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "user_profile" DROP COLUMN "listenbrainz"
|
||||
`);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ import type { Promiseable } from '@/misc/prelude/await-all.js';
|
|||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
||||
import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
|
||||
import type { MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
||||
import { birthdaySchema, descriptionSchema, localUsernameSchema, locationSchema, nameSchema, passwordSchema } from '@/models/User.js';
|
||||
import { birthdaySchema, listenbrainzSchema, descriptionSchema, localUsernameSchema, locationSchema, nameSchema, passwordSchema } from '@/models/User.js';
|
||||
import type { UsersRepository, UserSecurityKeysRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, MutingsRepository, DriveFilesRepository, NoteUnreadsRepository, UserNotePiningsRepository, UserProfilesRepository, AnnouncementReadsRepository, AnnouncementsRepository, MiUserProfile, RenoteMutingsRepository, UserMemoRepository } from '@/models/_.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
|
@ -139,6 +139,7 @@ export class UserEntityService implements OnModuleInit {
|
|||
public validateDescription = ajv.compile(descriptionSchema);
|
||||
public validateLocation = ajv.compile(locationSchema);
|
||||
public validateBirthday = ajv.compile(birthdaySchema);
|
||||
public validateListenBrainz = ajv.compile(listenbrainzSchema);
|
||||
//#endregion
|
||||
|
||||
public isLocalUser = isLocalUser;
|
||||
|
@ -381,6 +382,7 @@ export class UserEntityService implements OnModuleInit {
|
|||
description: profile!.description,
|
||||
location: profile!.location,
|
||||
birthday: profile!.birthday,
|
||||
listenbrainz: profile!.listenbrainz,
|
||||
lang: profile!.lang,
|
||||
fields: profile!.fields,
|
||||
verifiedLinks: profile!.verifiedLinks,
|
||||
|
|
|
@ -280,4 +280,5 @@ export const passwordSchema = { type: 'string', minLength: 1 } as const;
|
|||
export const nameSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
|
||||
export const descriptionSchema = { type: 'string', minLength: 1, maxLength: 1500 } as const;
|
||||
export const locationSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
|
||||
export const listenbrainzSchema = { type: "string", minLength: 1, maxLength: 128 } as const;
|
||||
export const birthdaySchema = { type: 'string', pattern: /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.toString().slice(1, -1) } as const;
|
||||
|
|
|
@ -34,6 +34,13 @@ export class MiUserProfile {
|
|||
})
|
||||
public birthday: string | null;
|
||||
|
||||
@Column("varchar", {
|
||||
length: 128,
|
||||
nullable: true,
|
||||
comment: "The ListenBrainz username of the User.",
|
||||
})
|
||||
public listenbrainz: string | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 2048, nullable: true,
|
||||
comment: 'The description (bio) of the User.',
|
||||
|
|
|
@ -145,6 +145,12 @@ export const packedUserDetailedNotMeOnlySchema = {
|
|||
nullable: true, optional: false,
|
||||
example: '2018-03-12',
|
||||
},
|
||||
ListenBrainz: {
|
||||
type: "string",
|
||||
nullable: true,
|
||||
optional: false,
|
||||
example: "Steve",
|
||||
},
|
||||
lang: {
|
||||
type: 'string',
|
||||
nullable: true, optional: false,
|
||||
|
|
|
@ -13,7 +13,7 @@ import { extractHashtags } from '@/misc/extract-hashtags.js';
|
|||
import * as Acct from '@/misc/acct.js';
|
||||
import type { UsersRepository, DriveFilesRepository, UserProfilesRepository, PagesRepository } from '@/models/_.js';
|
||||
import type { MiLocalUser, MiUser } from '@/models/User.js';
|
||||
import { birthdaySchema, descriptionSchema, locationSchema, nameSchema } from '@/models/User.js';
|
||||
import { birthdaySchema, listenbrainzSchema, descriptionSchema, locationSchema, nameSchema } from '@/models/User.js';
|
||||
import type { MiUserProfile } from '@/models/UserProfile.js';
|
||||
import { notificationTypes } from '@/types.js';
|
||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||
|
@ -129,6 +129,7 @@ export const paramDef = {
|
|||
description: { ...descriptionSchema, nullable: true },
|
||||
location: { ...locationSchema, nullable: true },
|
||||
birthday: { ...birthdaySchema, nullable: true },
|
||||
listenbrainz: { ...listenbrainzSchema, nullable: true },
|
||||
lang: { type: 'string', enum: [null, ...Object.keys(langmap)] as string[], nullable: true },
|
||||
avatarId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||
bannerId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||
|
@ -224,6 +225,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (ps.lang !== undefined) profileUpdates.lang = ps.lang;
|
||||
if (ps.location !== undefined) profileUpdates.location = ps.location;
|
||||
if (ps.birthday !== undefined) profileUpdates.birthday = ps.birthday;
|
||||
if (ps.listenbrainz !== undefined) profileUpdates.listenbrainz = ps.listenbrainz;
|
||||
if (ps.ffVisibility !== undefined) profileUpdates.ffVisibility = ps.ffVisibility;
|
||||
if (ps.mutedWords !== undefined) {
|
||||
// TODO: ちゃんと数える
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue