fix: better handling of missing of invalid to, cc, timestamp values

This commit is contained in:
Julian Lam
2024-02-13 12:03:16 -05:00
parent 814c479405
commit 76d5feb7d6
2 changed files with 4 additions and 6 deletions

View File

@@ -72,11 +72,9 @@ inbox.like = async (req) => {
inbox.announce = async (req) => { inbox.announce = async (req) => {
const { actor, object, published, to, cc } = req.body; const { actor, object, published, to, cc } = req.body;
let timestamp = Date.now(); let timestamp = new Date(published);
try { if (timestamp.toString() === 'Invalid Date') {
timestamp = new Date(published).getTime(); timestamp = Date.now();
} catch (e) {
// ok to fail
} }
const assertion = await activitypub.actors.assert(actor); const assertion = await activitypub.actors.assert(actor);

View File

@@ -59,7 +59,7 @@ Notes.assert = async (uid, input, options = {}) => {
}; };
Notes.updateLocalRecipients = async (id, { to, cc }) => { Notes.updateLocalRecipients = async (id, { to, cc }) => {
const recipients = new Set([...to, ...cc]); const recipients = new Set([...(to || []), ...(cc || [])]);
const uids = new Set(); const uids = new Set();
await Promise.all(Array.from(recipients).map(async (recipient) => { await Promise.all(Array.from(recipients).map(async (recipient) => {
const { type, id } = await activitypub.helpers.resolveLocalId(recipient); const { type, id } = await activitypub.helpers.resolveLocalId(recipient);