diff --git a/src/components/Composer.vue b/src/components/Composer.vue index abb0eb9c4b..cca91db64d 100644 --- a/src/components/Composer.vue +++ b/src/components/Composer.vue @@ -476,11 +476,12 @@ import UnfoldMoreHorizontal from 'vue-material-design-icons/UnfoldMoreHorizontal import UnfoldLessHorizontal from 'vue-material-design-icons/UnfoldLessHorizontal.vue' import Paperclip from 'vue-material-design-icons/Paperclip.vue' import IconFormat from 'vue-material-design-icons/FormatSize.vue' +import {namespaces as NS} from '@nextcloud/cdav-library' import { showError, showWarning } from '@nextcloud/dialogs' import { getCanonicalLocale, getFirstDay, getLocale, translate as t } from '@nextcloud/l10n' import Vue from 'vue' -import mitt from 'mitt' +import mitt from 'mitt' import { findRecipient } from '../service/AutocompleteService.js' import { detect, html, plain, toHtml, toPlain } from '../util/text.js' import logger from '../logger.js' @@ -1244,6 +1245,21 @@ export default { }, onNewToAddr(option) { this.onNewAddr(option, this.selectTo, 'to') + this.$store.getters.getAddressBooks.forEach(addressBook => { + console.info(addressBook) + addressBook.addressbookQuery([{ + name: [NS.IETF_CARDDAV, 'comp-filter'], + attributes: [['name', 'VCARD']], + children: [{ + name: [NS.IETF_CARDDAV, 'prop-filter'], + attributes: [['name', 'EMAIL']], + children: [{ + name: [NS.IETF_CALDAV, 'text-match'], + value: option.email, + }], + }], + }]) + }) }, onNewCcAddr(option) { this.onNewAddr(option, this.selectCc, 'cc') diff --git a/src/service/caldavService.js b/src/service/caldavService.js index aaa4e86c77..f459b9f784 100644 --- a/src/service/caldavService.js +++ b/src/service/caldavService.js @@ -45,7 +45,10 @@ const getClient = () => { * Initializes the client for use in the user-view */ export async function initializeClientForUserView() { - await getClient().connect({ enableCalDAV: true }) + await getClient().connect({ + enableCalDAV: true, + enableCardDAV: true, + }) } /** @@ -66,11 +69,23 @@ export function getCalendarHome() { return getClient().calendarHomes[0] } +/** + * Fetch all address books from the server + * + * @return {Promise} + */ +export function getAddressBookHomes() { + return getClient().addressBookHomes[0] +} + /** * Fetch all collections in the calendar home from the server * * @return {Promise} */ export async function findAll() { - return await getCalendarHome().findAllCalDAVCollectionsGrouped() + return { + calendarGroups: await getCalendarHome().findAllCalDAVCollectionsGrouped(), + addressBooks: await getAddressBookHomes().findAllAddressBooks(), + } } diff --git a/src/store/actions.js b/src/store/actions.js index 370c936d26..a1f7fa0878 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -1358,10 +1358,13 @@ export default { */ async loadCollections({ commit }) { await handleHttpAuthErrors(commit, async () => { - const { calendars } = await findAll() + const { calendarGroups: { calendars }, addressBooks } = await findAll() for (const calendar of calendars) { commit('addCalendar', { calendar }) } + for (const addressBook of addressBooks) { + commit('addAddressBook', { addressBook }) + } }) }, diff --git a/src/store/getters.js b/src/store/getters.js index 2dcd10b5c2..cf3e77e1d0 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -116,6 +116,7 @@ export const getters = { getCurrentUserPrincipal: (state) => state.currentUserPrincipal, getCurrentUserPrincipalEmail: (state) => state.currentUserPrincipal?.email, getCalendars: (state) => state.calendars, + getAddressBooks: (state) => state.addressBooks, getClonedCalendars: (state) => state.calendars.map(calendar => { // Hack: We need to clone all calendars because some methods (e.g. calendarQuery) are // unnecessarily mutating the object and causing vue warnings (if used outside of diff --git a/src/store/index.js b/src/store/index.js index 8ff6ea2a44..f2b245beff 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -103,6 +103,7 @@ export default new Store({ masterPasswordEnabled: false, sieveScript: {}, calendars: [], + addressBooks: [], smimeCertificates: [], hasFetchedInitialEnvelopes: false, followUpFeatureAvailable: false, diff --git a/src/store/mutations.js b/src/store/mutations.js index 1dd378122a..0a09934432 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -480,6 +480,9 @@ export default { addCalendar(state, { calendar }) { state.calendars = [...state.calendars, calendar] }, + addAddressBook(state, { addressBook }) { + state.addressBooks = [...state.addressBooks, addressBook] + }, setGoogleOauthUrl(state, url) { state.googleOauthUrl = url },