Merge branch 'develop' of codeberg.org:calckey/calckey into develop
This commit is contained in:
commit
964bc9708a
@ -488,8 +488,8 @@ export const UserRepository = db.getRepository(User).extend({
|
||||
birthday: profile!.birthday,
|
||||
lang: profile!.lang,
|
||||
fields: profile!.fields,
|
||||
followersCount: followersCount || 0,
|
||||
followingCount: followingCount || 0,
|
||||
followersCount: followersCount || '?',
|
||||
followingCount: followingCount || '?',
|
||||
notesCount: user.notesCount,
|
||||
pinnedNoteIds: pins.map((pin) => pin.noteId),
|
||||
pinnedNotes: Notes.packMany(
|
||||
|
@ -198,9 +198,36 @@ export async function createPerson(
|
||||
const url = getOneApHrefNullable(person.url);
|
||||
|
||||
if (url && !url.startsWith("https://")) {
|
||||
throw new Error(`unexpected shcema of person url: ${url}`);
|
||||
throw new Error(`unexpected schema of person url: ${url}`);
|
||||
}
|
||||
|
||||
let followersCount: number | undefined;
|
||||
|
||||
if (typeof person.followers === "string") {
|
||||
try {
|
||||
let data = await fetch(person.followers, { headers: { "Accept": "application/json" } });
|
||||
let json_data = JSON.parse(await data.text());
|
||||
|
||||
followersCount = json_data.totalItems;
|
||||
} catch {
|
||||
followersCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
let followingCount: number | undefined;
|
||||
|
||||
if (typeof person.following === "string") {
|
||||
try {
|
||||
let data = await fetch(person.following, { headers: { "Accept": "application/json" } });
|
||||
let json_data = JSON.parse(await data.text());
|
||||
|
||||
followingCount = json_data.totalItems;
|
||||
} catch (e) {
|
||||
followingCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create user
|
||||
let user: IRemoteUser;
|
||||
try {
|
||||
@ -228,6 +255,16 @@ export async function createPerson(
|
||||
followersUri: person.followers
|
||||
? getApId(person.followers)
|
||||
: undefined,
|
||||
followersCount: followersCount !== undefined
|
||||
? followersCount
|
||||
: person.followers && typeof person.followers !== "string" && isCollectionOrOrderedCollection(person.followers)
|
||||
? person.followers.totalItems
|
||||
: undefined,
|
||||
followingCount: followingCount !== undefined
|
||||
? followingCount
|
||||
: person.following && typeof person.following !== "string" && isCollectionOrOrderedCollection(person.following)
|
||||
? person.following.totalItems
|
||||
: undefined,
|
||||
featured: person.featured ? getApId(person.featured) : undefined,
|
||||
uri: person.id,
|
||||
tags,
|
||||
@ -396,7 +433,34 @@ export async function updatePerson(
|
||||
const url = getOneApHrefNullable(person.url);
|
||||
|
||||
if (url && !url.startsWith("https://")) {
|
||||
throw new Error(`unexpected shcema of person url: ${url}`);
|
||||
throw new Error(`unexpected schema of person url: ${url}`);
|
||||
}
|
||||
|
||||
let followersCount: number | undefined;
|
||||
|
||||
if (typeof person.followers === "string") {
|
||||
try {
|
||||
let data = await fetch(person.followers, { headers: { "Accept": "application/json" } } );
|
||||
let json_data = JSON.parse(await data.text());
|
||||
|
||||
followersCount = json_data.totalItems;
|
||||
} catch {
|
||||
followersCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let followingCount: number | undefined;
|
||||
|
||||
if (typeof person.following === "string") {
|
||||
try {
|
||||
let data = await fetch(person.following, { headers: { "Accept": "application/json" } } );
|
||||
let json_data = JSON.parse(await data.text());
|
||||
|
||||
followingCount = json_data.totalItems;
|
||||
} catch {
|
||||
followingCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const updates = {
|
||||
@ -406,6 +470,16 @@ export async function updatePerson(
|
||||
person.sharedInbox ||
|
||||
(person.endpoints ? person.endpoints.sharedInbox : undefined),
|
||||
followersUri: person.followers ? getApId(person.followers) : undefined,
|
||||
followersCount: followersCount !== undefined
|
||||
? followersCount
|
||||
: person.followers && typeof person.followers !== "string" && isCollectionOrOrderedCollection(person.followers)
|
||||
? person.followers.totalItems
|
||||
: undefined,
|
||||
followingCount: followingCount !== undefined
|
||||
? followingCount
|
||||
: person.following && typeof person.following !== "string" && isCollectionOrOrderedCollection(person.following)
|
||||
? person.following.totalItems
|
||||
: undefined,
|
||||
featured: person.featured,
|
||||
emojis: emojiNames,
|
||||
name: truncate(person.name, nameLength),
|
||||
|
Loading…
Reference in New Issue
Block a user