-
Couldn't load subscription status.
- Fork 287
Fix request type impl #11758
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
base: main
Are you sure you want to change the base?
Fix request type impl #11758
Changes from all commits
679e96b
105a8d7
c493b7e
54fa869
6e2d4ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,7 @@ import { flatten } from 'ramda' | |
| import { showError } from '@nextcloud/dialogs' | ||
| import useMainStore from '../store/mainStore.js' | ||
| import { mapState } from 'pinia' | ||
| import { loadState } from '@nextcloud/initial-state' | ||
|
|
||
| // iMIP methods | ||
| const REQUEST = 'REQUEST' | ||
|
|
@@ -157,6 +158,22 @@ function findAttendee(vEvent, email) { | |
| return undefined | ||
| } | ||
|
|
||
| function findAttendeeByEmails(vEvent, emails) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, we recently changed the logic with #11915. Please ensure to rebase your branch and also re-test if that is still necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks |
||
| if (!vEvent || !Array.isArray(emails) || emails.length === 0) { | ||
| return undefined | ||
| } | ||
|
|
||
| const emailSet = new Set(emails.map(e => removeMailtoPrefix(e).toLowerCase())) | ||
| for (const attendee of [...vEvent.getPropertyIterator('ORGANIZER'), ...vEvent.getAttendeeIterator()]) { | ||
| const normalized = removeMailtoPrefix(attendee.email).toLowerCase() | ||
| if (emailSet.has(normalized)) { | ||
| return attendee | ||
| } | ||
| } | ||
|
|
||
| return undefined | ||
| } | ||
|
|
||
| export default { | ||
| name: 'Imip', | ||
| components: { | ||
|
|
@@ -173,6 +190,10 @@ export default { | |
| type: Object, | ||
| required: true, | ||
| }, | ||
| message: { | ||
| type: Object, | ||
| required: true, | ||
| }, | ||
| }, | ||
| data() { | ||
| return { | ||
|
|
@@ -190,13 +211,15 @@ export default { | |
| existingEventFetched: false, | ||
| targetCalendar: undefined, | ||
| comment: '', | ||
| digikalaDomain: loadState('mail', 'digikala_domain', '@digikala.com'), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard coded domain names and vendor specific variables, are not a good solution |
||
| } | ||
| }, | ||
| computed: { | ||
| ...mapState(useMainStore, { | ||
| currentUserPrincipalEmail: 'getCurrentUserPrincipalEmail', | ||
| clonedWriteableCalendars: 'getClonedWriteableCalendars', | ||
| currentUserPrincipal: 'getCurrentUserPrincipal', | ||
| accounts: 'getAccounts', | ||
| }), | ||
|
|
||
| /** | ||
|
|
@@ -208,6 +231,14 @@ export default { | |
| return this.scheduling.method | ||
| }, | ||
|
|
||
| isFromDigikala() { | ||
| if (!this.message.from || !this.message.from[0]) { | ||
| return false | ||
| } | ||
| const fromEmail = this.message.from[0].email?.toLowerCase() || '' | ||
| return fromEmail.endsWith(this.digikalaDomain) | ||
| }, | ||
|
|
||
|
Comment on lines
+234
to
+241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vendor specific variables and method names, are not a good solution |
||
| /** | ||
| * @return {boolean} | ||
| */ | ||
|
|
@@ -305,7 +336,7 @@ export default { | |
| * @return {boolean} | ||
| */ | ||
| userIsAttendee() { | ||
| return !!findAttendee(this.attachedVEvent, this.currentUserPrincipalEmail) | ||
| return !!findAttendeeByEmails(this.attachedVEvent, this.allUserEmails) | ||
| }, | ||
|
|
||
| /** | ||
|
|
@@ -314,10 +345,38 @@ export default { | |
| * @return {string|undefined} | ||
| */ | ||
| existingParticipationStatus() { | ||
| const attendee = findAttendee(this.existingVEvent, this.currentUserPrincipalEmail) | ||
| const attendee = findAttendeeByEmails(this.existingVEvent, this.allUserEmails) | ||
| return attendee?.participationStatus ?? undefined | ||
| }, | ||
|
|
||
| /** | ||
| * All user's email addresses (principal + all mail account addresses and aliases) | ||
| * | ||
| * @return {string[]} | ||
| */ | ||
| allUserEmails() { | ||
| const emails = new Set() | ||
| if (this.currentUserPrincipalEmail) { | ||
| emails.add(this.currentUserPrincipalEmail.toLowerCase()) | ||
| } | ||
| if (Array.isArray(this.accounts)) { | ||
| for (const account of this.accounts) { | ||
| if (account?.emailAddress) { | ||
| emails.add(String(account.emailAddress).toLowerCase()) | ||
| } | ||
| if (Array.isArray(account?.aliases)) { | ||
| for (const alias of account.aliases) { | ||
| const address = alias?.alias || alias?.emailAddress | ||
| if (address) { | ||
| emails.add(String(address).toLowerCase()) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return Array.from(emails) | ||
| }, | ||
|
|
||
| /** | ||
| * The status message to show in case of REPLY messages. | ||
| * | ||
|
|
@@ -352,6 +411,14 @@ export default { | |
| }) | ||
| }, | ||
|
|
||
| existingEventFetched: { | ||
| immediate: false, | ||
| async handler(fetched) { | ||
| if (!fetched) return | ||
| await this.autoCreateTentativeIfNeeded() | ||
| }, | ||
| }, | ||
|
|
||
| /** | ||
| * List of calendar options for the target calendar picker. | ||
| * | ||
|
|
@@ -410,6 +477,14 @@ export default { | |
| }, | ||
| }, | ||
| }, | ||
|
|
||
| async mounted() { | ||
| // If data already fetched on mount, attempt auto-create once | ||
| if (this.existingEventFetched) { | ||
| await this.autoCreateTentativeIfNeeded() | ||
| } | ||
| }, | ||
|
|
||
| methods: { | ||
| async accept() { | ||
| await this.saveEventWithParticipationStatus(ACCEPTED) | ||
|
|
@@ -420,6 +495,22 @@ export default { | |
| async decline() { | ||
| await this.saveEventWithParticipationStatus(DECLINED) | ||
| }, | ||
| async autoCreateTentativeIfNeeded() { | ||
| try { | ||
| if ( | ||
| this.isRequest | ||
| && !this.wasProcessed | ||
| && this.userIsAttendee | ||
| && this.eventIsInFuture | ||
| && this.existingEventFetched | ||
| && !this.isExistingEvent | ||
| ) { | ||
| await this.saveEventWithParticipationStatus(TENTATIVE) | ||
| } | ||
| } catch (e) { | ||
| // ignore auto-create failures | ||
| } | ||
| }, | ||
| async saveEventWithParticipationStatus(status) { | ||
| let vCalendar | ||
| if (this.isExistingEvent) { | ||
|
|
@@ -428,7 +519,7 @@ export default { | |
| vCalendar = this.attachedVCalendar | ||
| } | ||
| const vEvent = vCalendar.getFirstComponent('VEVENT') | ||
| const attendee = findAttendee(vEvent, this.currentUserPrincipalEmail) | ||
| const attendee = findAttendeeByEmails(vEvent, this.allUserEmails) | ||
| if (!attendee) { | ||
| return | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,7 @@ export default { | |
| computed: { | ||
| enhancedBody() { | ||
| return this.body.replace(/(^>.*\n)+/gm, (match) => { | ||
| return `<details class="quoted-text"><summary>${t('mail', 'Quoted text')}</summary>${match}</details>` | ||
| return `<details class="quoted-text" open><summary>${t('mail', 'Quoted text')}</summary>${match}</details>` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This appears to be unrelated, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, it's not directly related. I noticed that in some cases incoming emails were not fully displayed — parts of the message body were being cut off. I added this change to fix that rendering issue and ensure the full email content is shown properly. |
||
| }) | ||
| }, | ||
| signatureSummaryAndBody() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard coded domain names and vendor specific variables, are not a good solution