Skip to content

Commit

Permalink
Fix cc and to can be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
llun committed Feb 24, 2025
1 parent a343169 commit 06021ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/jobs/createNoteJob.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Note } from '@llun/activities.schema'
import identity from 'lodash/identity'

import { recordActorIfNeeded } from '../actions/utils'
import {
Expand Down Expand Up @@ -48,8 +49,8 @@ export const createNoteJob = createJobHandle(
text,
summary,

to: Array.isArray(note.to) ? note.to : [note.to].filter((item) => item),
cc: Array.isArray(note.cc) ? note.cc : [note.cc].filter((item) => item),
to: Array.isArray(note.to) ? note.to : [note.to].filter(identity),
cc: Array.isArray(note.cc) ? note.cc : [note.cc].filter(identity),

reply: compactNote.inReplyTo || '',
createdAt: new Date(compactNote.published).getTime()
Expand Down
13 changes: 9 additions & 4 deletions lib/models/status.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ENTITY_TYPE_QUESTION, Note, Question } from '@llun/activities.schema'
import identity from 'lodash/identity'
import { z } from 'zod'

import { AnnounceStatus } from '@/lib/activities/actions/announceStatus'
Expand Down Expand Up @@ -104,8 +105,8 @@ export const fromNote = (note: Note): StatusNote => {
text: getContent(note),
summary: getSummary(note),

to: Array.isArray(note.to) ? note.to : [note.to],
cc: Array.isArray(note.cc) ? note.cc : [note.cc],
to: Array.isArray(note.to) ? note.to : [note.to].filter(identity),
cc: Array.isArray(note.cc) ? note.cc : [note.cc].filter(identity),
edits: [],

reply: note.inReplyTo || '',
Expand Down Expand Up @@ -148,8 +149,12 @@ export const fromAnnoucne = (

type: StatusType.enum.Announce,

to: Array.isArray(announce.to) ? announce.to : [announce.to],
cc: Array.isArray(announce.cc) ? announce.cc : [announce.cc],
to: Array.isArray(announce.to)
? announce.to
: [announce.to].filter(identity),
cc: Array.isArray(announce.cc)
? announce.cc
: [announce.cc].filter(identity),
edits: [],

originalStatus,
Expand Down

0 comments on commit 06021ca

Please sign in to comment.