From 043ad5ed59c09da2d8f9e9bb9d39536b645928b0 Mon Sep 17 00:00:00 2001 From: Nekromateion <43814053+Nekromateion@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:28:54 +0200 Subject: [PATCH] Prevent auto invite attempts when not allowed to (#820) * Prevent auto invite attempts when not allowed to Prevent the application from trying to auto invite the user to the instance when the local user does not have permissions to invite to the instance. * Add try catch to auto invite block Add try catch to auto invite block to prevent error messages from popping up when they shouldn't --- html/src/app.js | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 4bad957f..fcc07826 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -14889,7 +14889,6 @@ speechSynthesis.getVoices(); currentLocation = $app.lastLocationDestination; } if (!currentLocation) return; - var L = this.parseLocation(currentLocation); if ( $app.autoAcceptInviteRequests === 'All Favorites' && !$app.favoriteFriends.some((x) => x.id === ref.senderUserId) @@ -14902,22 +14901,31 @@ speechSynthesis.getVoices(); ) return; - this.getCachedWorld({ - worldId: L.worldId - }).then((args1) => { - this.sendInvite( - { - instanceId: L.tag, - worldId: L.tag, - worldName: args1.ref.name, - rsvp: true - }, - ref.senderUserId - ).then((_args) => { - $app.$message(`Auto invite sent to ${ref.senderUsername}`); - return _args; + if (!this.checkCanInvite(currentLocation)) + return; + + var L = this.parseLocation(currentLocation); + + try { + this.getCachedWorld({ + worldId: L.worldId + }).then((args1) => { + this.sendInvite( + { + instanceId: L.tag, + worldId: L.tag, + worldName: args1.ref.name, + rsvp: true + }, + ref.senderUserId + ).then((_args) => { + $app.$message(`Auto invite sent to ${ref.senderUsername}`); + return _args; + }); }); - }); + } catch (err) { + console.error(err); + } }); $app.data.unseenNotifications = [];