diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ae948d0..294461c4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ You should also include the user name that made the change. Your own theme color may be unset if it was in an invalid format. Admins should check their instance settings if in doubt. - Perform port diagnosis at startup only when Listen fails @mei23 +- Add pronouns to vCard and display when replying @ThatOneCalculator ### Bugfixes - Client: fix settings page @tamaina diff --git a/locales/en-US.yml b/locales/en-US.yml index a7d69d6d4..f542512f1 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -258,6 +258,7 @@ remoteUserCaution: "As this user is from a remote instance, the shown informatio activity: "Activity" images: "Images" birthday: "Birthday" +pronouns: "Pronouns" yearsOld: "{age} years old" registeredDate: "Joined on" location: "Location" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index f64246d15..563ad5c95 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -258,6 +258,7 @@ remoteUserCaution: "リモートユーザーのため、情報が不完全です activity: "アクティビティ" images: "画像" birthday: "誕生日" +pronouns: "代名詞" yearsOld: "{age}歳" registeredDate: "登録日" location: "場所" diff --git a/packages/backend/src/models/entities/user-profile.ts b/packages/backend/src/models/entities/user-profile.ts index 1778742ea..0f923bffb 100644 --- a/packages/backend/src/models/entities/user-profile.ts +++ b/packages/backend/src/models/entities/user-profile.ts @@ -17,6 +17,12 @@ export class UserProfile { @JoinColumn() public user: User | null; + @Column('varchar', { + length: 32, nullable: true, + comment: 'The pronouns of the User.', + }) + public pronouns: string | null; + @Column('varchar', { length: 128, nullable: true, comment: 'The location of the User.', diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index 541fbaf00..a6404245e 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -16,7 +16,7 @@ const userInstanceCache = new Cache(1000 * 60 * 60 * 3); type IsUserDetailed = Detailed extends true ? Packed<'UserDetailed'> : Packed<'UserLite'>; type IsMeAndIsUserDetailed = - Detailed extends true ? + Detailed extends true ? ExpectsMe extends true ? Packed<'MeDetailed'> : ExpectsMe extends false ? Packed<'UserDetailedNotMe'> : Packed<'UserDetailed'> : @@ -30,6 +30,7 @@ const nameSchema = { type: 'string', minLength: 1, maxLength: 50 } as const; const descriptionSchema = { type: 'string', minLength: 1, maxLength: 500 } as const; const locationSchema = { type: 'string', minLength: 1, maxLength: 50 } as const; const birthdaySchema = { type: 'string', pattern: /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.toString().slice(1, -1) } as const; +const pronounsSchema = { type: 'string', minLength: 1, maxLength: 20 } as const; function isLocalUser(user: User): user is ILocalUser; function isLocalUser(user: T): user is T & { host: null; }; @@ -50,6 +51,7 @@ export const UserRepository = db.getRepository(User).extend({ descriptionSchema, locationSchema, birthdaySchema, + pronounsSchema, //#region Validators validateLocalUsername: ajv.compile(localUsernameSchema), @@ -58,6 +60,7 @@ export const UserRepository = db.getRepository(User).extend({ validateDescription: ajv.compile(descriptionSchema), validateLocation: ajv.compile(locationSchema), validateBirthday: ajv.compile(birthdaySchema), + validatePronouns: ajv.compile(pronounsSchema), //#endregion async getRelation(me: User['id'], target: User['id']) { @@ -318,6 +321,7 @@ export const UserRepository = db.getRepository(User).extend({ isSilenced: user.isSilenced || falsy, isSuspended: user.isSuspended || falsy, description: profile!.description, + pronouns: profile!.pronouns, location: profile!.location, birthday: profile!.birthday, lang: profile!.lang, diff --git a/packages/backend/src/models/schema/user.ts b/packages/backend/src/models/schema/user.ts index 253681695..97fe79fe0 100644 --- a/packages/backend/src/models/schema/user.ts +++ b/packages/backend/src/models/schema/user.ts @@ -143,6 +143,11 @@ export const packedUserDetailedNotMeOnlySchema = { nullable: true, optional: false, example: 'Hi masters, I am Ai!', }, + pronouns: { + type: 'string', + nullable: true, optional: false, + example: 'They/Them', + }, location: { type: 'string', nullable: true, optional: false, diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts index 6097e3b6e..8f37ba599 100644 --- a/packages/backend/src/remote/activitypub/models/person.ts +++ b/packages/backend/src/remote/activitypub/models/person.ts @@ -192,6 +192,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise { if (ps.name !== undefined) updates.name = ps.name; if (ps.description !== undefined) profileUpdates.description = ps.description; if (ps.lang !== undefined) profileUpdates.lang = ps.lang; + if (ps.pronouns !== undefined) profileUpdates.pronouns = ps.pronouns; if (ps.location !== undefined) profileUpdates.location = ps.location; if (ps.birthday !== undefined) profileUpdates.birthday = ps.birthday; if (ps.ffVisibility !== undefined) profileUpdates.ffVisibility = ps.ffVisibility; diff --git a/packages/client/src/pages/settings/profile.vue b/packages/client/src/pages/settings/profile.vue index e991d725b..c01ed4396 100644 --- a/packages/client/src/pages/settings/profile.vue +++ b/packages/client/src/pages/settings/profile.vue @@ -17,6 +17,11 @@ + + + + + @@ -82,6 +87,7 @@ import { langmap } from '@/scripts/langmap'; const profile = reactive({ name: $i.name, description: $i.description, + pronouns: $i.pronouns, location: $i.location, birthday: $i.birthday, lang: $i.lang, @@ -120,6 +126,7 @@ function save() { os.apiWithDialog('i/update', { name: profile.name || null, description: profile.description || null, + pronouns: profile.pronouns || null, location: profile.location || null, birthday: profile.birthday || null, lang: profile.lang || null, diff --git a/packages/client/src/pages/user/index.vue b/packages/client/src/pages/user/index.vue index 17e815892..d3ff3aef2 100644 --- a/packages/client/src/pages/user/index.vue +++ b/packages/client/src/pages/user/index.vue @@ -47,6 +47,10 @@

{{ $ts.noAccountDescription }}

+
+
{{ $ts.pronouns }}
+
{{ user.pronouns }}
+
{{ $ts.location }}
{{ user.location }}