14 lines
531 B
TypeScript
Raw Permalink Normal View History

2024-12-31 13:55:42 +01:00
import type {Entity} from '../api'
2024-12-30 23:50:15 +01:00
import vCard from 'vcf'
2024-08-22 01:44:50 +02:00
export const entityToName = (e: { entity: Entity }): string => {
if (e.entity.jCard.length === 0) return e.entity.handle
const jCard = vCard.fromJSON(e.entity.jCard)
let name = e.entity.handle
2024-12-20 19:41:48 +01:00
if (jCard.data.org && !Array.isArray(jCard.data.org) && jCard.data.org.valueOf() !== '') name = jCard.data.org.valueOf()
2024-12-22 22:13:27 +01:00
if (jCard.data.fn && !Array.isArray(jCard.data.fn) && jCard.data.fn.valueOf() !== '') name = jCard.data.fn.valueOf()
2024-12-20 19:41:48 +01:00
2024-08-22 01:44:50 +02:00
return name
2024-12-30 23:50:15 +01:00
}