mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-24 05:03:08 +02:00
upd: federate listenbrainz, fix background federation
This commit is contained in:
parent
f81d6f8e24
commit
67cfa53118
4 changed files with 15 additions and 4 deletions
|
@ -523,6 +523,10 @@ export class ApRendererService {
|
||||||
person['vcard:Address'] = profile.location;
|
person['vcard:Address'] = profile.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (profile.listenbrainz) {
|
||||||
|
person.listenbrainz = profile.listenbrainz;
|
||||||
|
}
|
||||||
|
|
||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -797,6 +801,7 @@ export class ApRendererService {
|
||||||
// Sharkey
|
// Sharkey
|
||||||
sharkey: "https://joinsharkey.org/ns#",
|
sharkey: "https://joinsharkey.org/ns#",
|
||||||
backgroundUrl: "sharkey:backgroundUrl",
|
backgroundUrl: "sharkey:backgroundUrl",
|
||||||
|
listenbrainz: "sharkey:listenbrainz",
|
||||||
// vcard
|
// vcard
|
||||||
vcard: 'http://www.w3.org/2006/vcard/ns#',
|
vcard: 'http://www.w3.org/2006/vcard/ns#',
|
||||||
},
|
},
|
||||||
|
|
|
@ -225,8 +225,8 @@ export class ApPersonService implements OnModuleInit {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async resolveAvatarAndBanner(user: MiRemoteUser, icon: any, image: any): Promise<Pick<MiRemoteUser, 'avatarId' | 'bannerId' | 'backgroundId' | 'avatarUrl' | 'bannerUrl' | 'backgroundUrl' | 'avatarBlurhash' | 'bannerBlurhash' | 'backgroundBlurhash'>> {
|
private async resolveAvatarAndBanner(user: MiRemoteUser, icon: any, image: any, bgimg: any): Promise<Pick<MiRemoteUser, 'avatarId' | 'bannerId' | 'backgroundId' | 'avatarUrl' | 'bannerUrl' | 'backgroundUrl' | 'avatarBlurhash' | 'bannerBlurhash' | 'backgroundBlurhash'>> {
|
||||||
const [avatar, banner, background] = await Promise.all([icon, image].map(img => {
|
const [avatar, banner, background] = await Promise.all([icon, image, bgimg].map(img => {
|
||||||
if (img == null) return null;
|
if (img == null) return null;
|
||||||
if (user == null) throw new Error('failed to create user: user is null');
|
if (user == null) throw new Error('failed to create user: user is null');
|
||||||
return this.apImageService.resolveImage(user, img).catch(() => null);
|
return this.apImageService.resolveImage(user, img).catch(() => null);
|
||||||
|
@ -307,6 +307,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
id: this.idService.genId(),
|
id: this.idService.genId(),
|
||||||
avatarId: null,
|
avatarId: null,
|
||||||
bannerId: null,
|
bannerId: null,
|
||||||
|
backgroundId: null,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastFetchedAt: new Date(),
|
lastFetchedAt: new Date(),
|
||||||
name: truncate(person.name, nameLength),
|
name: truncate(person.name, nameLength),
|
||||||
|
@ -341,6 +342,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
birthday: bday?.[0] ?? null,
|
birthday: bday?.[0] ?? null,
|
||||||
location: person['vcard:Address'] ?? null,
|
location: person['vcard:Address'] ?? null,
|
||||||
userHost: host,
|
userHost: host,
|
||||||
|
listenbrainz: person.listenbrainz ?? null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (person.publicKey) {
|
if (person.publicKey) {
|
||||||
|
@ -386,7 +388,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
|
|
||||||
//#region アバターとヘッダー画像をフェッチ
|
//#region アバターとヘッダー画像をフェッチ
|
||||||
try {
|
try {
|
||||||
const updates = await this.resolveAvatarAndBanner(user, person.icon, person.image);
|
const updates = await this.resolveAvatarAndBanner(user, person.icon, person.image, person.backgroundUrl);
|
||||||
await this.usersRepository.update(user.id, updates);
|
await this.usersRepository.update(user.id, updates);
|
||||||
user = { ...user, ...updates };
|
user = { ...user, ...updates };
|
||||||
|
|
||||||
|
@ -469,7 +471,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
movedToUri: person.movedTo ?? null,
|
movedToUri: person.movedTo ?? null,
|
||||||
alsoKnownAs: person.alsoKnownAs ?? null,
|
alsoKnownAs: person.alsoKnownAs ?? null,
|
||||||
isExplorable: person.discoverable,
|
isExplorable: person.discoverable,
|
||||||
...(await this.resolveAvatarAndBanner(exist, person.icon, person.image).catch(() => ({}))),
|
...(await this.resolveAvatarAndBanner(exist, person.icon, person.image, person.backgroundUrl).catch(() => ({}))),
|
||||||
} as Partial<MiRemoteUser> & Pick<MiRemoteUser, 'isBot' | 'isCat' | 'speakAsCat' | 'isLocked' | 'movedToUri' | 'alsoKnownAs' | 'isExplorable'>;
|
} as Partial<MiRemoteUser> & Pick<MiRemoteUser, 'isBot' | 'isCat' | 'speakAsCat' | 'isLocked' | 'movedToUri' | 'alsoKnownAs' | 'isExplorable'>;
|
||||||
|
|
||||||
const moving = ((): boolean => {
|
const moving = ((): boolean => {
|
||||||
|
@ -508,6 +510,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
description: person.summary ? this.apMfmService.htmlToMfm(truncate(person.summary, summaryLength), person.tag) : null,
|
description: person.summary ? this.apMfmService.htmlToMfm(truncate(person.summary, summaryLength), person.tag) : null,
|
||||||
birthday: bday?.[0] ?? null,
|
birthday: bday?.[0] ?? null,
|
||||||
location: person['vcard:Address'] ?? null,
|
location: person['vcard:Address'] ?? null,
|
||||||
|
listenbrainz: person.listenbrainz ?? null,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.globalEventService.publishInternalEvent('remoteUserUpdated', { id: exist.id });
|
this.globalEventService.publishInternalEvent('remoteUserUpdated', { id: exist.id });
|
||||||
|
|
|
@ -183,6 +183,8 @@ export interface IActor extends IObject {
|
||||||
};
|
};
|
||||||
'vcard:bday'?: string;
|
'vcard:bday'?: string;
|
||||||
'vcard:Address'?: string;
|
'vcard:Address'?: string;
|
||||||
|
listenbrainz?: string;
|
||||||
|
backgroundUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isCollection = (object: IObject): object is ICollection =>
|
export const isCollection = (object: IObject): object is ICollection =>
|
||||||
|
|
|
@ -38,6 +38,7 @@ export type UserDetailed = UserLite & {
|
||||||
backgroundUrl: string | null;
|
backgroundUrl: string | null;
|
||||||
backgroundBlurhash: string | null;
|
backgroundBlurhash: string | null;
|
||||||
birthday: string | null;
|
birthday: string | null;
|
||||||
|
listenbrainz: string | null;
|
||||||
createdAt: DateString;
|
createdAt: DateString;
|
||||||
description: string | null;
|
description: string | null;
|
||||||
ffVisibility: 'public' | 'followers' | 'private';
|
ffVisibility: 'public' | 'followers' | 'private';
|
||||||
|
|
Loading…
Reference in a new issue