-
Notifications
You must be signed in to change notification settings - Fork 84
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
Accept an optional web-client argument for the invite. #326
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
.vscode/ | ||
*.iml | ||
_trial_temp | ||
*.egg | ||
*.egg-info | ||
.python-version | ||
|
||
# Runtime files | ||
sydent.conf | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Accept an optional `web_client_location` argument to the invite endpoint which allows customisation of the email template. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,29 +79,37 @@ def render_POST(self, request): | |
tokenStore.storeEphemeralPublicKey(ephemeralPublicKeyBase64) | ||
tokenStore.storeToken(medium, address, roomId, sender, token) | ||
|
||
# Variables to substitute in the template. | ||
substitutions = {} | ||
# Include all arguments sent via the request. | ||
for k, v in args.items(): | ||
if isinstance(v, string_types): | ||
substitutions[k] = v | ||
substitutions["token"] = token | ||
|
||
required = [ | ||
# Substitutions that the template requires, but are optional to provide | ||
# to the API. | ||
extra_substitutions = [ | ||
'sender_display_name', | ||
'token', | ||
'room_name', | ||
'bracketed_room_name', | ||
'room_avatar_url', | ||
'sender_display_name', | ||
'sender_avatar_url', | ||
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. Oh this is an unrelated fix, but |
||
'guest_user_id', | ||
'guest_access_token', | ||
] | ||
for k in required: | ||
for k in extra_substitutions: | ||
substitutions.setdefault(k, '') | ||
|
||
substitutions["ephemeral_private_key"] = ephemeralPrivateKeyBase64 | ||
if substitutions["room_name"] != '': | ||
substitutions["bracketed_room_name"] = "(%s)" % substitutions["room_name"] | ||
|
||
substitutions["web_client_location"] = self.sydent.default_web_client_location | ||
if 'org.matrix.web_client_location' in substitutions: | ||
substitutions["web_client_location"] = substitutions.pop("org.matrix.web_client_location") | ||
|
||
subject_header = Header(self.sydent.cfg.get('email', 'email.invite.subject', raw=True) % substitutions, 'utf8') | ||
substitutions["subject_header_value"] = subject_header.encode() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is still quite Element-specific. Would this work with Hydrogen for instance? We could be fancy and allow the client to provide a URL filled with named placeholders.
Perhaps we don't care about this for right now though.
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.
I'll see if it is reasonable for a homeserver to calculate the other items here. 👍
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.
The way that sydent currently works I don't think this is easily doable since a unique key is included in this URL that sydent generates (
ephemeral_private_key
), see the code around:sydent/sydent/http/servlets/store_invite_servlet.py
Lines 71 to 80 in c55007f
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.
I see, thanks for digging. Note that I think we've talked about this key being either unhelpful or broken in Synapse's current implementation: matrix-org/synapse#6036