mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-11-28 14:58:09 +09:00
Merge pull request '[PR]: fix: take invalid expiresAt of polls as null' (#10279) from nmkj/calckey:fix-poll-expire into develop
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/10279
This commit is contained in:
commit
d769a1fc23
@ -34,6 +34,9 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
|
|||||||
const info = Object.assign({}, activity) as any;
|
const info = Object.assign({}, activity) as any;
|
||||||
info["@context"] = undefined;
|
info["@context"] = undefined;
|
||||||
logger.debug(JSON.stringify(info, null, 2));
|
logger.debug(JSON.stringify(info, null, 2));
|
||||||
|
|
||||||
|
if (!signature?.keyId) return `Invalid signature: ${signature}`;
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
const host = toPuny(new URL(signature.keyId).hostname);
|
const host = toPuny(new URL(signature.keyId).hostname);
|
||||||
|
|
||||||
|
@ -718,14 +718,23 @@ async function insertNote(
|
|||||||
if (insert.hasPoll) {
|
if (insert.hasPoll) {
|
||||||
// Start transaction
|
// Start transaction
|
||||||
await db.transaction(async (transactionalEntityManager) => {
|
await db.transaction(async (transactionalEntityManager) => {
|
||||||
|
if (!data.poll) throw new Error("Empty poll data");
|
||||||
|
|
||||||
await transactionalEntityManager.insert(Note, insert);
|
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({
|
const poll = new Poll({
|
||||||
noteId: insert.id,
|
noteId: insert.id,
|
||||||
choices: data.poll!.choices,
|
choices: data.poll.choices,
|
||||||
expiresAt: data.poll!.expiresAt,
|
expiresAt,
|
||||||
multiple: data.poll!.multiple,
|
multiple: data.poll.multiple,
|
||||||
votes: new Array(data.poll!.choices.length).fill(0),
|
votes: new Array(data.poll.choices.length).fill(0),
|
||||||
noteVisibility: insert.visibility,
|
noteVisibility: insert.visibility,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
userHost: user.host,
|
userHost: user.host,
|
||||||
|
Loading…
Reference in New Issue
Block a user