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) => {
const { actor, object, published, to, cc } = req.body;
let timestamp = Date.now();
try {
timestamp = new Date(published).getTime();
} catch (e) {
// ok to fail
let timestamp = new Date(published);
if (timestamp.toString() === 'Invalid Date') {
timestamp = Date.now();
}
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 }) => {
const recipients = new Set([...to, ...cc]);
const recipients = new Set([...(to || []), ...(cc || [])]);
const uids = new Set();
await Promise.all(Array.from(recipients).map(async (recipient) => {
const { type, id } = await activitypub.helpers.resolveLocalId(recipient);