Skip to content

Commit

Permalink
fix: added link to invite message
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathixx committed Jul 11, 2024
1 parent 794b996 commit ed0f03d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
23 changes: 16 additions & 7 deletions packages/matrix-identity-server/src/invitation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,32 @@ const preConfigureTemplate = (

// TODO : don't forget to modify this : cf matrix.to or other method
const inviteLink = (
method: 'matrix.org' | 'twake.org',
address: string,
name: string
server: string,
senderId: string,
roomAlias?: string
): string => {
return `https://${method}/${address}/${name}`
if (roomAlias != null) {
return `https://${server}/#/${roomAlias}`
} else {
return `https://${server}/#/${senderId}`
}
}

const mailBody = (
template: string,
// eslint-disable-next-line @typescript-eslint/naming-convention
inviter_name: string,
// eslint-disable-next-line @typescript-eslint/naming-convention
sender_user_id: string,
dst: string,
// eslint-disable-next-line @typescript-eslint/naming-convention
room_name: string,
// eslint-disable-next-line @typescript-eslint/naming-convention
room_avatar: string,
// eslint-disable-next-line @typescript-eslint/naming-convention
room_type: string
room_type: string,
// eslint-disable-next-line @typescript-eslint/naming-convention
room_alias?: string
): string => {
return (
template
Expand All @@ -90,7 +97,7 @@ const mailBody = (
.replace(/__room_name__/g, room_name)
.replace(/__room_avatar__/g, room_avatar)
.replace(/__room_type__/g, room_type)
.replace(/__link__/g, inviteLink('matrix.org', dst, room_name))
.replace(/__link__/g, inviteLink('matrix.to', sender_user_id, room_alias))
)
}

Expand Down Expand Up @@ -216,10 +223,12 @@ const StoreInvit = <T extends string = never>(
verificationTemplate,
(obj as storeInvitationArgs).sender_display_name ??
'*****',
(obj as storeInvitationArgs).sender,
_address,
(obj as storeInvitationArgs).room_name ?? '*****',
(obj as storeInvitationArgs).room_avatar_url ?? '*****',
(obj as storeInvitationArgs).room_type ?? '*****'
(obj as storeInvitationArgs).room_type ?? '*****',
(obj as storeInvitationArgs).room_alias
)
})
break
Expand Down
4 changes: 2 additions & 2 deletions packages/matrix-identity-server/templates/3pidInvitation.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Content-Type: text/plain; charset=UTF-8
Content-Disposition: inline
Hello,

You have been invited to join a Matrix room by __inviter_name__.
You have been invited to join the __room_name__ Matrix room by __inviter_name__.
Please click on the following link to accept the invitation: __link__

About Matrix:
Expand Down Expand Up @@ -40,7 +40,7 @@ body {
<body>
<p>Hello,</p>

<p>You have been invited to join a Matrix room by __inviter_name__. Please click on the following link to accept the invitation: <a href="__link__">__link__</a></p>
<p>You have been invited to join the __room_name__ Matrix room by __inviter_name__. Please click on the following link to accept the invitation: <a href="__link__">__link__</a></p>

<p>About Matrix:</p>

Expand Down

0 comments on commit ed0f03d

Please sign in to comment.