| 2 | import { SerializedReaction } from '@linen/types'; |
| 3 | |
| 4 | export function serializeReaction( |
| 5 | reaction: messageReactions |
| 6 | ): SerializedReaction { |
| 7 | return { |
| 8 | type: reaction.name, |
| 9 | count: reaction.count as number, |
| 10 | users: |
| 11 | reaction.users && Array.isArray(reaction.users) |
| 12 | ? (reaction.users as string[]).map((id: string) => { |
| 13 | // our prisma.schema keeps reactions as json |
| 14 | // instead of a users relation |
| 15 | // we should fix it in the future |
| 16 | return { |
| 17 | authsId: null, |
| 18 | username: null, |
| 19 | displayName: null, |
| 20 | externalUserId: null, |
| 21 | profileImageUrl: null, |
| 22 | id, |
| 23 | }; |
| 24 | }) |
| 25 | : [], |
| 26 | }; |
| 27 | } |