Skip to content
Open
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
17 changes: 16 additions & 1 deletion src/components/Editor/Invitees/InviteesListSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<div v-if="option.type === 'circle' || option.type === 'contactsgroup'">
{{ option.subtitle }}
</div>
<div v-else-if="option.looksLikeMailingList" class="invitees-search-list-item__warning">
<AlertCircleOutline :size="14" />
{{ $t('calendar', 'This might be a mailing list. Invitations will not work.') }}
</div>
</div>
</div>
</template>
Expand All @@ -62,12 +66,13 @@
} from '@nextcloud/vue'
import debounce from 'debounce'
import GoogleCirclesCommunitiesIcon from 'vue-material-design-icons/GoogleCirclesCommunities.vue'
import AlertCircleOutline from 'vue-material-design-icons/AlertCircleOutline.vue'

Check failure on line 69 in src/components/Editor/Invitees/InviteesListSearch.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "vue-material-design-icons/AlertCircleOutline.vue" to come before "vue-material-design-icons/GoogleCirclesCommunities.vue"
import {
circleGetMembers,
circleSearchByName,
} from '../../../services/circleService.js'
import isCirclesEnabled from '../../../services/isCirclesEnabled.js'
import { removeMailtoPrefix } from '../../../utils/attendee.js'
import { looksLikeMailingList, removeMailtoPrefix } from '../../../utils/attendee.js'
import { randomId } from '../../../utils/randomId.js'

export default {
Expand All @@ -76,6 +81,7 @@
Avatar,
NcSelect,
GoogleCirclesCommunitiesIcon,
AlertCircleOutline,
},

props: {
Expand Down Expand Up @@ -145,6 +151,7 @@
timezoneId: null,
hasMultipleEMails: false,
dropdownName: query,
looksLikeMailingList: looksLikeMailingList(query),
})
}
}
Expand Down Expand Up @@ -281,6 +288,7 @@
timezoneId: result.tzid,
hasMultipleEMails,
dropdownName: name + ' ' + email,
looksLikeMailingList: looksLikeMailingList(email),
})
})

Expand Down Expand Up @@ -318,4 +326,11 @@
:deep(.avatardiv) {
overflow: visible !important;
}

.invitees-search-list-item__warning {
display: flex;
align-items: center;
gap: 4px;
color: var(--color-warning);
}
</style>
55 changes: 55 additions & 0 deletions src/utils/attendee.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,61 @@
return removeMailtoPrefix(organizer.uri)
}

/**
* Heuristically check if an email address looks like a mailing list address
*
* @param {string} email Email address to check (with or without mailto: prefix)
* @return {boolean} True if the address looks like a mailing list
*/
export function looksLikeMailingList(email) {
if (typeof email !== 'string') {
return false
}

const address = removeMailtoPrefix(email).toLowerCase()
const atIndex = address.indexOf('@')
if (atIndex === -1) {
return false
}

const local = address.slice(0, atIndex)
const domain = address.slice(atIndex + 1)

const exactMatches = new Set([
'list', 'lists', 'ml', 'announce', 'announcements', 'noreply', 'no-reply',

Check failure on line 81 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''no-reply''

Check failure on line 81 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''noreply''

Check failure on line 81 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''announcements''

Check failure on line 81 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''announce''

Check failure on line 81 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''ml''

Check failure on line 81 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''lists''
'newsletter', 'newsletters', 'mailer-daemon', 'postmaster', 'sympa',

Check failure on line 82 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''postmaster''

Check failure on line 82 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''mailer-daemon''

Check failure on line 82 in src/utils/attendee.js

View workflow job for this annotation

GitHub Actions / NPM lint

Should have line break between ',' and ''newsletters''
'majordomo', 'listserv', 'mailman', 'dmarc', 'bounce', 'bounces',
'subscribe', 'unsubscribe',
])
if (exactMatches.has(local)) {
return true
}

const suffixes = [
'-bounces', '-request', '-subscribe', '-unsubscribe', '-owner', '-help',
'-announce', '-devel', '-discuss', '-commits', '-bugs', '-patches',
'-users', '-list', '+bounces', '+subscribe',
]
if (suffixes.some((s) => local.endsWith(s))) {
return true
}

const knownDomains = new Set([
'googlegroups.com', 'groups.io', 'freelists.org',
'yahoogroups.com', 'listserv.com', 'topica.com',
])
if (knownDomains.has(domain)) {
return true
}

const knownSubdomainPrefixes = ['lists.', 'ml.', 'listserv.', 'mailman.', 'sympa.']
if (knownSubdomainPrefixes.some((p) => domain.startsWith(p))) {
return true
}

return false
}

/**
* Check if the current user is an attendee
*
Expand Down
46 changes: 46 additions & 0 deletions tests/javascript/unit/utils/attendee.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import {
addMailtoPrefix,
looksLikeMailingList,
organizerDisplayName,
removeMailtoPrefix,
} from '../../../../src/utils/attendee'
Expand Down Expand Up @@ -33,6 +34,51 @@ describe('utils/attendee test suite', () => {
expect(addMailtoPrefix(undefined)).toEqual("mailto:")
})

describe('looksLikeMailingList', () => {
it('detects exact local-part matches', () => {
expect(looksLikeMailingList('announce@example.com')).toBe(true)
expect(looksLikeMailingList('mailman@example.org')).toBe(true)
expect(looksLikeMailingList('noreply@example.com')).toBe(true)
expect(looksLikeMailingList('lists@example.com')).toBe(true)
})

it('detects local-part suffix matches', () => {
expect(looksLikeMailingList('dev-bounces@example.org')).toBe(true)
expect(looksLikeMailingList('project-request@example.com')).toBe(true)
expect(looksLikeMailingList('calendar-users@example.com')).toBe(true)
expect(looksLikeMailingList('app+bounces@example.com')).toBe(true)
})

it('detects known mailing list domains', () => {
expect(looksLikeMailingList('group@googlegroups.com')).toBe(true)
expect(looksLikeMailingList('list@groups.io')).toBe(true)
expect(looksLikeMailingList('user@freelists.org')).toBe(true)
})

it('detects known mailing list subdomains', () => {
expect(looksLikeMailingList('user@lists.nextcloud.com')).toBe(true)
expect(looksLikeMailingList('someone@mailman.apache.org')).toBe(true)
expect(looksLikeMailingList('foo@sympa.example.com')).toBe(true)
})

it('handles mailto: prefix', () => {
expect(looksLikeMailingList('mailto:announce@example.com')).toBe(true)
expect(looksLikeMailingList('mailto:john@example.com')).toBe(false)
})

it('returns false for regular email addresses', () => {
expect(looksLikeMailingList('john@example.com')).toBe(false)
expect(looksLikeMailingList('dev@example.com')).toBe(false)
expect(looksLikeMailingList('alice@company.com')).toBe(false)
})

it('returns false for invalid input', () => {
expect(looksLikeMailingList('notanemail')).toBe(false)
expect(looksLikeMailingList(null)).toBe(false)
expect(looksLikeMailingList(undefined)).toBe(false)
})
})

it('should extract a display name of an organizer', () => {
const commonName = 'My Name'
const uri = 'uri@test.com'
Expand Down
Loading