Merge pull request #2306 from matrix-org/travis/cors-on-join

Suppress CORS errors in the 'failed to join room' dialog
pull/21833/head
Travis Ralston 2018-12-05 13:53:24 -07:00 committed by GitHub
commit daa0ddd21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -222,6 +222,7 @@
"Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions", "Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions",
"Not a valid Riot keyfile": "Not a valid Riot keyfile", "Not a valid Riot keyfile": "Not a valid Riot keyfile",
"Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?", "Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?",
"There was an error joining the room": "There was an error joining the room",
"Use a few words, avoid common phrases": "Use a few words, avoid common phrases", "Use a few words, avoid common phrases": "Use a few words, avoid common phrases",
"No need for symbols, digits, or uppercase letters": "No need for symbols, digits, or uppercase letters", "No need for symbols, digits, or uppercase letters": "No need for symbols, digits, or uppercase letters",
"Use a longer keyboard pattern with more turns": "Use a longer keyboard pattern with more turns", "Use a longer keyboard pattern with more turns": "Use a longer keyboard pattern with more turns",

View File

@ -224,6 +224,11 @@ class RoomViewStore extends Store {
err: err, err: err,
}); });
let msg = err.message ? err.message : JSON.stringify(err); let msg = err.message ? err.message : JSON.stringify(err);
// XXX: We are relying on the error message returned by browsers here.
// This isn't great, but it does generalize the error being shown to users.
if (msg && msg.startsWith("CORS request rejected")) {
msg = _t("There was an error joining the room");
}
if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') { if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') {
msg = <div> msg = <div>
{_t("Sorry, your homeserver is too old to participate in this room.")}<br /> {_t("Sorry, your homeserver is too old to participate in this room.")}<br />