Merge branch 'Marie-develop-patch-33974' into 'develop'
feat: Fetch total posts of users on create/update Closes #10652 See merge request firefish/firefish!10558
This commit is contained in:
commit
c4018c969c
1 changed files with 47 additions and 1 deletions
|
@ -231,6 +231,21 @@ export async function createPerson(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let notesCount: number | undefined;
|
||||||
|
|
||||||
|
if (typeof person.outbox === "string") {
|
||||||
|
try {
|
||||||
|
let data = await fetch(person.outbox, {
|
||||||
|
headers: { Accept: "application/json" },
|
||||||
|
});
|
||||||
|
let json_data = JSON.parse(await data.text());
|
||||||
|
|
||||||
|
notesCount = json_data.totalItems;
|
||||||
|
} catch (e) {
|
||||||
|
notesCount = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create user
|
// Create user
|
||||||
let user: IRemoteUser;
|
let user: IRemoteUser;
|
||||||
try {
|
try {
|
||||||
|
@ -274,6 +289,14 @@ export async function createPerson(
|
||||||
isCollectionOrOrderedCollection(person.following)
|
isCollectionOrOrderedCollection(person.following)
|
||||||
? person.following.totalItems
|
? person.following.totalItems
|
||||||
: undefined,
|
: undefined,
|
||||||
|
notesCount:
|
||||||
|
notesCount !== undefined
|
||||||
|
? notesCount
|
||||||
|
: person.outbox &&
|
||||||
|
typeof person.outbox !== "string" &&
|
||||||
|
isCollectionOrOrderedCollection(person.outbox)
|
||||||
|
? person.outbox.totalItems
|
||||||
|
: undefined,
|
||||||
featured: person.featured ? getApId(person.featured) : undefined,
|
featured: person.featured ? getApId(person.featured) : undefined,
|
||||||
uri: person.id,
|
uri: person.id,
|
||||||
tags,
|
tags,
|
||||||
|
@ -472,6 +495,21 @@ export async function updatePerson(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let notesCount: number | undefined;
|
||||||
|
|
||||||
|
if (typeof person.outbox === "string") {
|
||||||
|
try {
|
||||||
|
let data = await fetch(person.outbox, {
|
||||||
|
headers: { Accept: "application/json" },
|
||||||
|
});
|
||||||
|
let json_data = JSON.parse(await data.text());
|
||||||
|
|
||||||
|
notesCount = json_data.totalItems;
|
||||||
|
} catch (e) {
|
||||||
|
notesCount = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const updates = {
|
const updates = {
|
||||||
lastFetchedAt: new Date(),
|
lastFetchedAt: new Date(),
|
||||||
inbox: person.inbox,
|
inbox: person.inbox,
|
||||||
|
@ -495,6 +533,14 @@ export async function updatePerson(
|
||||||
isCollectionOrOrderedCollection(person.following)
|
isCollectionOrOrderedCollection(person.following)
|
||||||
? person.following.totalItems
|
? person.following.totalItems
|
||||||
: undefined,
|
: undefined,
|
||||||
|
notesCount:
|
||||||
|
notesCount !== undefined
|
||||||
|
? notesCount
|
||||||
|
: person.outbox &&
|
||||||
|
typeof person.outbox !== "string" &&
|
||||||
|
isCollectionOrOrderedCollection(person.outbox)
|
||||||
|
? person.outbox.totalItems
|
||||||
|
: undefined,
|
||||||
featured: person.featured,
|
featured: person.featured,
|
||||||
emojis: emojiNames,
|
emojis: emojiNames,
|
||||||
name: truncate(person.name, nameLength),
|
name: truncate(person.name, nameLength),
|
||||||
|
@ -663,7 +709,7 @@ export async function updateFeatured(userId: User["id"], resolver?: Resolver) {
|
||||||
? collection.items
|
? collection.items
|
||||||
: collection.orderedItems;
|
: collection.orderedItems;
|
||||||
const items = await Promise.all(
|
const items = await Promise.all(
|
||||||
toArray(unresolvedItems).map((x) => resolver.resolve(x)),
|
toArray(unresolvedItems).map((x) => resolver?.resolve(x)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Resolve and regist Notes
|
// Resolve and regist Notes
|
||||||
|
|
Loading…
Reference in a new issue