Skip to content

Commit

Permalink
ensure we don't accidentally send out invites when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Jan 12, 2024
1 parent 0b54630 commit 5585b87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/IRCBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixClient, MatrixEvent } from "matrix-bot-sdk";
import {LogService, MatrixClient, MatrixEvent} from "matrix-bot-sdk";
import * as irc from "irc-upd";
import { Auditorium } from "./models/Auditorium";
import { InterestRoom } from "./models/InterestRoom";
Expand Down Expand Up @@ -128,7 +128,8 @@ export class IRCBridge {

public async plumbChannelToRoom(channel: string, roomId: string) {
if (await this.shouldInviteBot(roomId)) {
await this.mxClient.inviteUser(this.config.botUserId, roomId);
//await this.mxClient.inviteUser(this.config.botUserId, roomId);
LogService.info("IRCBridge", `Inviting ${this.config.botUserId}`)
}
await this.ircClient.join(channel);
const result = await this.executeCommand(`plumb ${roomId} ${this.config.serverName} ${channel}`);
Expand Down
26 changes: 14 additions & 12 deletions src/invites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export async function resolveIdentifiers(client: ConferenceMatrixClient, people:

export async function invitePersonToRoom(client: ConferenceMatrixClient, resolvedPerson: ResolvedPersonIdentifier, roomId: string): Promise<void> {
if (resolvedPerson.mxid) {
return await client.inviteUser(resolvedPerson.mxid.trim(), roomId);
//return await client.inviteUser(resolvedPerson.mxid.trim(), roomId);
LogService.info("invites", `Inviting ${resolvedPerson.mxid}`)
}

if (!resolvedPerson.emails) {
Expand All @@ -93,16 +94,17 @@ export async function invitePersonToRoom(client: ConferenceMatrixClient, resolve
}

for (const email of resolvedPerson.emails) {
const idInvite = await client.identityClient.makeEmailInvite(email, roomId);
const content = {
display_name: idInvite.display_name,
// XXX: https://github.com/matrix-org/matrix-doc/issues/2948
key_validity_url: `${client.identityClient.serverUrl}/_matrix/identity/v2/pubkey/ephemeral/isvalid`,
public_key: idInvite.public_key,
public_keys: idInvite.public_keys,
[RS_3PID_PERSON_ID]: resolvedPerson.person.id,
};
const stateKey = idInvite.token; // not included in the content
await client.sendStateEvent(roomId, "m.room.third_party_invite", stateKey, content);
// const idInvite = await client.identityClient.makeEmailInvite(email, roomId);
// const content = {
// display_name: idInvite.display_name,
// // XXX: https://github.com/matrix-org/matrix-doc/issues/2948
// key_validity_url: `${client.identityClient.serverUrl}/_matrix/identity/v2/pubkey/ephemeral/isvalid`,
// public_key: idInvite.public_key,
// public_keys: idInvite.public_keys,
// [RS_3PID_PERSON_ID]: resolvedPerson.person.id,
// };
// const stateKey = idInvite.token; // not included in the content
// await client.sendStateEvent(roomId, "m.room.third_party_invite", stateKey, content);
LogService.info("invites", `Third-party inviting ${email}`)
}
}

0 comments on commit 5585b87

Please sign in to comment.