(
userId: string,
addressBookId: string,
)
| 49 | |
| 50 | export class ContactModel { |
| 51 | static async list( |
| 52 | userId: string, |
| 53 | addressBookId: string, |
| 54 | ): Promise<Contact[]> { |
| 55 | const client = await getClient(userId); |
| 56 | |
| 57 | const addressBookUrl = `${contactsConfig.cardDavUrl}/${userId}/${addressBookId}/`; |
| 58 | |
| 59 | const davContacts: DAVObject[] = await client.fetchVCards({ |
| 60 | addressBook: { |
| 61 | url: addressBookUrl, |
| 62 | }, |
| 63 | }); |
| 64 | |
| 65 | const contacts: Contact[] = davContacts.map((davContact) => { |
| 66 | return { |
| 67 | ...davContact, |
| 68 | ...parseVCard(davContact.data || '')[0], |
| 69 | }; |
| 70 | }); |
| 71 | |
| 72 | return contacts; |
| 73 | } |
| 74 | |
| 75 | static async get( |
| 76 | userId: string, |
no test coverage detected