Skip to content

Commit

Permalink
Allow Matrix-inviting users even if they were previously e-mail-invited
Browse files Browse the repository at this point in the history
and show diagnostic info for this
  • Loading branch information
reivilibre committed Jan 23, 2025
1 parent d4c102f commit 10e8a08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/commands/InviteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,14 @@ export class InviteCommand implements ICommand {
// List of Matrix user IDs that have already joined
const effectiveJoinedUserIds: string[] = members.filter(m => m.effectiveMembership === "join").map(m => m.membershipFor);
for (const target of people) {
if (target.mxid && effectiveJoinedUserIds.includes(target.mxid)) continue;
if (emailInvitePersonIds.includes(target.person.id)) continue;
if (target.mxid) {
if (effectiveJoinedUserIds.includes(target.mxid)) continue;
} else {
// Notably: don't stop Matrix-inviting a user just because they had
// previously been e-mail-invited
if (emailInvitePersonIds.includes(target.person.id)) continue;
}

try {
await invitePersonToRoom(this.client, target, roomId, this.config);
} catch (e) {
Expand Down
8 changes: 5 additions & 3 deletions src/commands/VerifyCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface PersonState {
bestKind: 'matrix' | 'e-mail' | 'uncontactable',

// what's the current state of this person in this room?
membership: 'invited' | 'joined' | 'missing'
membership: 'invited' | 'joined' | 'missing' | 'invited-but-by-e-mail'
}

export class VerifyCommand implements ICommand {
Expand Down Expand Up @@ -70,7 +70,7 @@ export class VerifyCommand implements ICommand {

let state =peopleToStates.get(target.id);
if (state) {
html += ` (best contact method: ${state.bestKind}; membership: ${state.membership})`;
html += ` (best method: <u>${state.bestKind}</u>; membership: <u>${state.membership}</u>)`;
} else {
html += " (unknown state)";
}
Expand Down Expand Up @@ -122,14 +122,16 @@ export class VerifyCommand implements ICommand {
const effectiveInvitedUserIds: string[] = members.filter(m => m.effectiveMembership === "invite").map(m => m.membershipFor);
for (const person of resolved) {
let bestKind: 'matrix' | 'e-mail' | 'uncontactable' = 'uncontactable';
let state: 'invited' | 'joined' | 'missing' = 'missing';
let state: 'invited' | 'joined' | 'missing' | 'invited-but-by-e-mail' = 'missing';

if (person.mxid) {
bestKind = 'matrix';
if (effectiveJoinedUserIds.includes(person.mxid)) {
state = 'joined';
} else if (effectiveInvitedUserIds.includes(person.mxid)) {
state = 'invited';
} else if (emailInvitePersonIds.includes(person.person.id)) {
state = 'invited-but-by-e-mail';
}
} else if (person.emails) {
bestKind = 'e-mail';
Expand Down

0 comments on commit 10e8a08

Please sign in to comment.