fix inbox stall

This commit is contained in:
Namekuji 2023-06-07 09:16:41 -04:00
parent f49f8bf8f7
commit ab9b9e5bff
No known key found for this signature in database
GPG Key ID: B541BD6E646CABC7
2 changed files with 16 additions and 4 deletions

View File

@ -34,6 +34,9 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
const info = Object.assign({}, activity) as any;
info["@context"] = undefined;
logger.debug(JSON.stringify(info, null, 2));
if (!signature?.keyId) return `Invalid signature: ${signature}`;
//#endregion
const host = toPuny(new URL(signature.keyId).hostname);

View File

@ -718,14 +718,23 @@ async function insertNote(
if (insert.hasPoll) {
// Start transaction
await db.transaction(async (transactionalEntityManager) => {
if (!data.poll) throw new Error("Empty poll data");
await transactionalEntityManager.insert(Note, insert);
let expiresAt: Date | null;
if (!data.poll.expiresAt || isNaN(data.poll.expiresAt.getTime())) {
expiresAt = null;
} else {
expiresAt = data.poll.expiresAt;
}
const poll = new Poll({
noteId: insert.id,
choices: data.poll!.choices,
expiresAt: data.poll!.expiresAt,
multiple: data.poll!.multiple,
votes: new Array(data.poll!.choices.length).fill(0),
choices: data.poll.choices,
expiresAt,
multiple: data.poll.multiple,
votes: new Array(data.poll.choices.length).fill(0),
noteVisibility: insert.visibility,
userId: user.id,
userHost: user.host,