mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 14:05:04 +08:00
Merge pull request #3385 from matrix-org/jryans/email-invite-text
Improve email invite preview messaging
This commit is contained in:
commit
3cb06c01b7
@ -35,6 +35,8 @@ const MessageCase = Object.freeze({
|
|||||||
Kicked: "Kicked",
|
Kicked: "Kicked",
|
||||||
Banned: "Banned",
|
Banned: "Banned",
|
||||||
OtherThreePIDError: "OtherThreePIDError",
|
OtherThreePIDError: "OtherThreePIDError",
|
||||||
|
InvitedEmailNotFoundInAccount: "InvitedEmailNotFoundInAccount",
|
||||||
|
InvitedEmailNoIdentityServer: "InvitedEmailNoIdentityServer",
|
||||||
InvitedEmailMismatch: "InvitedEmailMismatch",
|
InvitedEmailMismatch: "InvitedEmailMismatch",
|
||||||
Invite: "Invite",
|
Invite: "Invite",
|
||||||
ViewingRoom: "ViewingRoom",
|
ViewingRoom: "ViewingRoom",
|
||||||
@ -106,12 +108,24 @@ module.exports = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_checkInvitedEmail: async function() {
|
_checkInvitedEmail: async function() {
|
||||||
// If this is an invite and we've been told what email
|
// If this is an invite and we've been told what email address was
|
||||||
// address was invited, fetch the user's list of Threepids
|
// invited, fetch the user's account emails and discovery bindings so we
|
||||||
// so we can check them against the one that was invited
|
// can check them against the email that was invited.
|
||||||
if (this.props.inviterName && this.props.invitedEmail) {
|
if (this.props.inviterName && this.props.invitedEmail) {
|
||||||
this.setState({busy: true});
|
this.setState({busy: true});
|
||||||
try {
|
try {
|
||||||
|
// Gather the account 3PIDs
|
||||||
|
const account3pids = await MatrixClientPeg.get().getThreePids();
|
||||||
|
this.setState({
|
||||||
|
accountEmails: account3pids.threepids
|
||||||
|
.filter(b => b.medium === 'email').map(b => b.address),
|
||||||
|
});
|
||||||
|
// If we have an IS connected, use that to lookup the email and
|
||||||
|
// check the bound MXID.
|
||||||
|
if (!MatrixClientPeg.get().getIdentityServerUrl()) {
|
||||||
|
this.setState({busy: false});
|
||||||
|
return;
|
||||||
|
}
|
||||||
const authClient = new IdentityAuthClient();
|
const authClient = new IdentityAuthClient();
|
||||||
const identityAccessToken = await authClient.getAccessToken();
|
const identityAccessToken = await authClient.getAccessToken();
|
||||||
const result = await MatrixClientPeg.get().lookupThreePid(
|
const result = await MatrixClientPeg.get().lookupThreePid(
|
||||||
@ -157,6 +171,13 @@ module.exports = React.createClass({
|
|||||||
if (this.props.invitedEmail) {
|
if (this.props.invitedEmail) {
|
||||||
if (this.state.threePidFetchError) {
|
if (this.state.threePidFetchError) {
|
||||||
return MessageCase.OtherThreePIDError;
|
return MessageCase.OtherThreePIDError;
|
||||||
|
} else if (
|
||||||
|
this.state.accountEmails &&
|
||||||
|
!this.state.accountEmails.includes(this.props.invitedEmail)
|
||||||
|
) {
|
||||||
|
return MessageCase.InvitedEmailNotFoundInAccount;
|
||||||
|
} else if (!MatrixClientPeg.get().getIdentityServerUrl()) {
|
||||||
|
return MessageCase.InvitedEmailNoIdentityServer;
|
||||||
} else if (this.state.invitedEmailMxid != MatrixClientPeg.get().getUserId()) {
|
} else if (this.state.invitedEmailMxid != MatrixClientPeg.get().getUserId()) {
|
||||||
return MessageCase.InvitedEmailMismatch;
|
return MessageCase.InvitedEmailMismatch;
|
||||||
}
|
}
|
||||||
@ -337,8 +358,10 @@ module.exports = React.createClass({
|
|||||||
title = _t("Something went wrong with your invite to %(roomName)s",
|
title = _t("Something went wrong with your invite to %(roomName)s",
|
||||||
{roomName: this._roomName()});
|
{roomName: this._roomName()});
|
||||||
const joinRule = this._joinRule();
|
const joinRule = this._joinRule();
|
||||||
const errCodeMessage = _t("%(errcode)s was returned while trying to valide your invite. You could try to pass this information on to a room admin.",
|
const errCodeMessage = _t(
|
||||||
{errcode: this.state.threePidFetchError.errcode},
|
"An error (%(errcode)s) was returned while trying to validate your " +
|
||||||
|
"invite. You could try to pass this information on to a room admin.",
|
||||||
|
{errcode: this.state.threePidFetchError.errcode || _t("unknown error code")},
|
||||||
);
|
);
|
||||||
switch (joinRule) {
|
switch (joinRule) {
|
||||||
case "invite":
|
case "invite":
|
||||||
@ -346,6 +369,8 @@ module.exports = React.createClass({
|
|||||||
_t("You can only join it with a working invite."),
|
_t("You can only join it with a working invite."),
|
||||||
errCodeMessage,
|
errCodeMessage,
|
||||||
];
|
];
|
||||||
|
primaryActionLabel = _t("Try to join anyway");
|
||||||
|
primaryActionHandler = this.props.onJoinClick;
|
||||||
break;
|
break;
|
||||||
case "public":
|
case "public":
|
||||||
subTitle = _t("You can still join it because this is a public room.");
|
subTitle = _t("You can still join it because this is a public room.");
|
||||||
@ -360,25 +385,51 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MessageCase.InvitedEmailNotFoundInAccount: {
|
||||||
|
title = _t(
|
||||||
|
"This invite to %(roomName)s was sent to %(email)s which is not " +
|
||||||
|
"associated with your account",
|
||||||
|
{
|
||||||
|
roomName: this._roomName(),
|
||||||
|
email: this.props.invitedEmail,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
subTitle = _t(
|
||||||
|
"Link this email with your account in Settings to receive invites " +
|
||||||
|
"directly in Riot.",
|
||||||
|
);
|
||||||
|
primaryActionLabel = _t("Join the discussion");
|
||||||
|
primaryActionHandler = this.props.onJoinClick;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MessageCase.InvitedEmailNoIdentityServer: {
|
||||||
|
title = _t(
|
||||||
|
"This invite to %(roomName)s was sent to %(email)s",
|
||||||
|
{
|
||||||
|
roomName: this._roomName(),
|
||||||
|
email: this.props.invitedEmail,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
subTitle = _t(
|
||||||
|
"Use an identity server in Settings to receive invites directly in Riot.",
|
||||||
|
);
|
||||||
|
primaryActionLabel = _t("Join the discussion");
|
||||||
|
primaryActionHandler = this.props.onJoinClick;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MessageCase.InvitedEmailMismatch: {
|
case MessageCase.InvitedEmailMismatch: {
|
||||||
title = _t("This invite to %(roomName)s wasn't sent to your account",
|
title = _t(
|
||||||
{roomName: this._roomName()});
|
"This invite to %(roomName)s was sent to %(email)s",
|
||||||
const joinRule = this._joinRule();
|
{
|
||||||
if (joinRule === "public") {
|
roomName: this._roomName(),
|
||||||
subTitle = _t("You can still join it because this is a public room.");
|
email: this.props.invitedEmail,
|
||||||
primaryActionLabel = _t("Join the discussion");
|
},
|
||||||
primaryActionHandler = this.props.onJoinClick;
|
);
|
||||||
} else {
|
subTitle = _t(
|
||||||
subTitle = _t(
|
"Share this email in Settings to receive invites directly in Riot.",
|
||||||
"Sign in with a different account, ask for another invite, or " +
|
);
|
||||||
"add the e-mail address %(email)s to this account.",
|
primaryActionLabel = _t("Join the discussion");
|
||||||
{email: this.props.invitedEmail},
|
primaryActionHandler = this.props.onJoinClick;
|
||||||
);
|
|
||||||
if (joinRule !== "invite") {
|
|
||||||
primaryActionLabel = _t("Try to join anyway");
|
|
||||||
primaryActionHandler = this.props.onJoinClick;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageCase.Invite: {
|
case MessageCase.Invite: {
|
||||||
|
@ -895,13 +895,17 @@
|
|||||||
"Re-join": "Re-join",
|
"Re-join": "Re-join",
|
||||||
"You were banned from %(roomName)s by %(memberName)s": "You were banned from %(roomName)s by %(memberName)s",
|
"You were banned from %(roomName)s by %(memberName)s": "You were banned from %(roomName)s by %(memberName)s",
|
||||||
"Something went wrong with your invite to %(roomName)s": "Something went wrong with your invite to %(roomName)s",
|
"Something went wrong with your invite to %(roomName)s": "Something went wrong with your invite to %(roomName)s",
|
||||||
"%(errcode)s was returned while trying to valide your invite. You could try to pass this information on to a room admin.": "%(errcode)s was returned while trying to valide your invite. You could try to pass this information on to a room admin.",
|
"An error (%(errcode)s) was returned while trying to validate your invite. You could try to pass this information on to a room admin.": "An error (%(errcode)s) was returned while trying to validate your invite. You could try to pass this information on to a room admin.",
|
||||||
|
"unknown error code": "unknown error code",
|
||||||
"You can only join it with a working invite.": "You can only join it with a working invite.",
|
"You can only join it with a working invite.": "You can only join it with a working invite.",
|
||||||
|
"Try to join anyway": "Try to join anyway",
|
||||||
"You can still join it because this is a public room.": "You can still join it because this is a public room.",
|
"You can still join it because this is a public room.": "You can still join it because this is a public room.",
|
||||||
"Join the discussion": "Join the discussion",
|
"Join the discussion": "Join the discussion",
|
||||||
"Try to join anyway": "Try to join anyway",
|
"This invite to %(roomName)s was sent to %(email)s which is not associated with your account": "This invite to %(roomName)s was sent to %(email)s which is not associated with your account",
|
||||||
"This invite to %(roomName)s wasn't sent to your account": "This invite to %(roomName)s wasn't sent to your account",
|
"Link this email with your account in Settings to receive invites directly in Riot.": "Link this email with your account in Settings to receive invites directly in Riot.",
|
||||||
"Sign in with a different account, ask for another invite, or add the e-mail address %(email)s to this account.": "Sign in with a different account, ask for another invite, or add the e-mail address %(email)s to this account.",
|
"This invite to %(roomName)s was sent to %(email)s": "This invite to %(roomName)s was sent to %(email)s",
|
||||||
|
"Use an identity server in Settings to receive invites directly in Riot.": "Use an identity server in Settings to receive invites directly in Riot.",
|
||||||
|
"Share this email in Settings to receive invites directly in Riot.": "Share this email in Settings to receive invites directly in Riot.",
|
||||||
"Do you want to chat with %(user)s?": "Do you want to chat with %(user)s?",
|
"Do you want to chat with %(user)s?": "Do you want to chat with %(user)s?",
|
||||||
"Do you want to join %(roomName)s?": "Do you want to join %(roomName)s?",
|
"Do you want to join %(roomName)s?": "Do you want to join %(roomName)s?",
|
||||||
"<userName/> invited you": "<userName/> invited you",
|
"<userName/> invited you": "<userName/> invited you",
|
||||||
@ -1402,7 +1406,6 @@
|
|||||||
"Collapse Reply Thread": "Collapse Reply Thread",
|
"Collapse Reply Thread": "Collapse Reply Thread",
|
||||||
"End-to-end encryption information": "End-to-end encryption information",
|
"End-to-end encryption information": "End-to-end encryption information",
|
||||||
"Failed to set Direct Message status of room": "Failed to set Direct Message status of room",
|
"Failed to set Direct Message status of room": "Failed to set Direct Message status of room",
|
||||||
"unknown error code": "unknown error code",
|
|
||||||
"Failed to forget room %(errCode)s": "Failed to forget room %(errCode)s",
|
"Failed to forget room %(errCode)s": "Failed to forget room %(errCode)s",
|
||||||
"All messages (noisy)": "All messages (noisy)",
|
"All messages (noisy)": "All messages (noisy)",
|
||||||
"All messages": "All messages",
|
"All messages": "All messages",
|
||||||
|
Loading…
Reference in New Issue
Block a user