Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/models/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ export default class Contact {

// if no rev set, init one
if (!this.vCard.hasProperty('rev')) {
this.vCard.addPropertyWithValue('rev', ICAL.VCardTime.now().convertToZone(ICAL.Timezone.utcTimezone))
const version = this.vCard.getFirstPropertyValue('version')
if (version === '4.0') {
this.vCard.addPropertyWithValue('rev', ICAL.Time.fromJSDate(new Date(), true))
}
if (version === '3.0') {
this.vCard.addPropertyWithValue('rev', ICAL.VCardTime.fromDateAndOrTimeString(new Date().toISOString(), 'date-time'))
}
}
}

Expand Down
28 changes: 10 additions & 18 deletions src/services/checks/invalidREV.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,29 @@ export default {
run: contact => {
try {
const hasRev = contact.vCard.hasProperty('rev')
const rev = hasRev && contact.vCard.getFirstProperty('rev')
const revValue = rev && rev.getFirstValue()

if (revValue) {
const version = contact.version
const type = revValue.icalclass

if (version === '3.0' && type === 'vcardtime') {
return false
}

if (version === '4.0' && type === 'icaltime') {
return false
}
}
return !hasRev
} catch (error) {
return true
}
return true
},

fix: contact => {
try {
// removing old invalid data
contact.vCard.removeProperty('rev')

// creatiing new value
contact.vCard.addPropertyWithValue('rev', ICAL.VCardTime.now().convertToZone(ICAL.Timezone.utcTimezone))
// creating new value
const version = contact.version
if (version === '4.0') {
contact.vCard.addPropertyWithValue('rev', ICAL.Time.fromJSDate(new Date(), true))
}
if (version === '3.0') {
contact.vCard.addPropertyWithValue('rev', ICAL.VCardTime.fromDateAndOrTimeString(new Date().toISOString(), 'date-time'))
}

return true
} catch (error) {
console.error('Error fixing invalid REV:', error)
return false
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/store/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ const actions = {
validate(contact)

// Update REV
if (contact.version === '4.0') {
contact.rev = ICAL.Time.fromJSDate(new Date(), true)
}
if (contact.version === '3.0') {
contact.rev = ICAL.VCardTime.fromDateAndOrTimeString(new Date().toISOString(), 'date-time')
}
contact.rev = ICAL.VCardTime.now().convertToZone(ICAL.Timezone.utcTimezone)

const vData = contact.toStringStripQuotes()
Expand Down
2 changes: 1 addition & 1 deletion src/views/Contacts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export default {

contact.fullName = t('contacts', 'Name')

contact.rev = ICAL.VCardTime.now().convertToZone(ICAL.Timezone.utcTimezone)
contact.rev = ICAL.Time.fromJSDate(new Date(), true)

// itterate over all properties (filter is not usable on objects and we need the key of the property)
const properties = rfcProps.properties
Expand Down
Loading