Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fetch VCARDs of composer recipients #9890

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,12 @@
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'

Check failure on line 482 in src/components/Composer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

A space is required after '{'

Check failure on line 482 in src/components/Composer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

A space is required before '}'
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'
Expand Down Expand Up @@ -1244,6 +1245,21 @@
},
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')
Expand Down
19 changes: 17 additions & 2 deletions src/service/caldavService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

/**
Expand All @@ -66,11 +69,23 @@ export function getCalendarHome() {
return getClient().calendarHomes[0]
}

/**
* Fetch all address books from the server
*
* @return {Promise<AddressBookHome>}
*/
export function getAddressBookHomes() {
return getClient().addressBookHomes[0]
}

/**
* Fetch all collections in the calendar home from the server
*
* @return {Promise<Collection[]>}
*/
export async function findAll() {
return await getCalendarHome().findAllCalDAVCollectionsGrouped()
return {
calendarGroups: await getCalendarHome().findAllCalDAVCollectionsGrouped(),
addressBooks: await getAddressBookHomes().findAllAddressBooks(),
}
}
5 changes: 4 additions & 1 deletion src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
})
},

Expand Down
1 change: 1 addition & 0 deletions src/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default new Store({
masterPasswordEnabled: false,
sieveScript: {},
calendars: [],
addressBooks: [],
smimeCertificates: [],
hasFetchedInitialEnvelopes: false,
followUpFeatureAvailable: false,
Expand Down
3 changes: 3 additions & 0 deletions src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
Loading