mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-29 09:58:07 +01:00
safer typings for userNeedsPublishing
and profileNeedsPublishing
This commit is contained in:
parent
02b600c9da
commit
1c65f23445
1 changed files with 12 additions and 6 deletions
|
@ -589,12 +589,15 @@ 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', 'hideOnlineStatus', 'enableRss'] as (keyof MiUser)[]) {
|
||||
const basicFields: (keyof MiUser)[] = ['avatarId', 'bannerId', 'backgroundId', 'isBot', 'username', 'name', 'isLocked', 'isExplorable', 'isCat', 'noindex', 'speakAsCat', 'movedToUri', 'alsoKnownAs', 'hideOnlineStatus', 'enableRss'];
|
||||
for (const field of basicFields) {
|
||||
if ((field in newUser) && oldUser[field] !== newUser[field]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (const arrayField of ['emojis', 'tags'] as (keyof MiUser)[]) {
|
||||
|
||||
const arrayFields: (keyof MiUser)[] = ['emojis', 'tags'];
|
||||
for (const arrayField of arrayFields) {
|
||||
if ((arrayField in newUser) !== (arrayField in oldUser)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -604,7 +607,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (!Array.isArray(oldArray) || !Array.isArray(newArray)) {
|
||||
return true;
|
||||
}
|
||||
if (oldArray.join("\0") !== newArray.join("\0")) {
|
||||
if (oldArray.join('\0') !== newArray.join('\0')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -612,12 +615,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
private profileNeedsPublishing(oldProfile: MiUserProfile, newProfile: Partial<MiUserProfile>): boolean {
|
||||
for (const field of ['description', 'followedMessage', 'birthday', 'location', 'listenbrainz'] as (keyof MiUserProfile)[]) {
|
||||
const basicFields: (keyof MiUserProfile)[] = ['description', 'followedMessage', 'birthday', 'location', 'listenbrainz'];
|
||||
for (const field of basicFields) {
|
||||
if ((field in newProfile) && oldProfile[field] !== newProfile[field]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (const arrayField of ['fields'] as (keyof MiUserProfile)[]) {
|
||||
|
||||
const arrayFields: (keyof MiUserProfile)[] = ['fields'];
|
||||
for (const arrayField of arrayFields) {
|
||||
if ((arrayField in newProfile) !== (arrayField in oldProfile)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -627,7 +633,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (!Array.isArray(oldArray) || !Array.isArray(newArray)) {
|
||||
return true;
|
||||
}
|
||||
if (oldArray.join("\0") !== newArray.join("\0")) {
|
||||
if (oldArray.join('\0') !== newArray.join('\0')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue