Files
domain-watchdog/assets/utils/functions/extractDetailsFromJCard.tsx
2024-12-30 23:50:15 +01:00

15 lines
531 B
TypeScript

import vCard from 'vcf'
import {Entity} from '../api'
export const extractDetailsFromJCard = (e: { entity: Entity }): {
fn?: string
organization?: string
} => {
if (e.entity.jCard.length === 0) return {fn: e.entity.handle}
const jCard = vCard.fromJSON(e.entity.jCard)
const fn = jCard.data.fn && !Array.isArray(jCard.data.fn) ? jCard.data.fn.valueOf() : undefined
const organization = jCard.data.org && !Array.isArray(jCard.data.org) ? jCard.data.org.valueOf() : undefined
return {fn, organization}
}