Implement Auto Accept Invite Request (#797)

Implementation for Auto Accepting of Invite Requests with multiple settings.
Off / All Favorites / Selected Favorites
This commit is contained in:
Nekromateion
2024-05-29 00:55:19 +02:00
committed by GitHub
parent de74a39945
commit fd20b08823
3 changed files with 81 additions and 1 deletions

View File

@@ -4856,6 +4856,12 @@ speechSynthesis.getVoices();
notificationId: content.id
}
});
this.$emit('PIPELINE:NOTIFICATION', {
json: content,
params: {
notificationId: content.id
}
});
break;
case 'notification-v2':
@@ -5483,6 +5489,7 @@ speechSynthesis.getVoices();
nextClearVRCXCacheCheck: 0,
nextDiscordUpdate: 0,
nextAutoStateChange: 0,
autoAcceptInviteRequests: 'Off',
isDiscordActive: false,
isGameRunning: false,
isGameNoVR: true,
@@ -14791,6 +14798,61 @@ speechSynthesis.getVoices();
$app.notificationTable.data = [];
});
API.$on('PIPELINE:NOTIFICATION', function (args) {
var ref = args.json;
if (ref.type !== 'requestInvite' || $app.autoAcceptInviteRequests === 'Off')
return;
var currentLocation = $app.lastLocation.location;
if ($app.lastLocation.location === 'traveling') {
currentLocation = $app.lastLocationDestination;
}
if (!currentLocation)
return;
var L = this.parseLocation(currentLocation);
switch ($app.autoAcceptInviteRequests) {
case 'All Favorites':
if (!$app.favoriteFriends.some(x => x.id === ref.senderUserId))
break;
this.getCachedWorld({
worldId: L.worldId
}).then((args) => {
this.sendInvite(
{
instanceId: L.tag,
worldId: L.tag,
worldName: args.ref.name,
rsvp: true
},
ref.senderUserId
).then((_args) => {
$app.$message('Auto Invite sent to ' + ref.senderUsername);
return _args;
});
});
break;
case 'Selected Favorites':
if (!$app.localFavoriteFriends.has(ref.senderUserId))
break;
this.getCachedWorld({
worldId: L.worldId
}).then((args) => {
this.sendInvite(
{
instanceId: L.tag,
worldId: L.tag,
worldName: args.ref.name,
rsvp: true
},
ref.senderUserId
).then((_args) => {
$app.$message('Auto Invite sent to ' + ref.senderUsername);
return _args;
});
});
break;
}
});
$app.data.unseenNotifications = [];
API.$on('NOTIFICATION', function (args) {
@@ -15625,11 +15687,19 @@ speechSynthesis.getVoices();
'VRCX_autoStateChange',
'Off'
);
$app.data.autoAcceptInviteRequests = await configRepository.getString(
'VRCX_autoAcceptInviteRequests',
'Off'
);
$app.methods.saveAutomationOptions = async function () {
await configRepository.setString(
'VRCX_autoStateChange',
this.autoStateChange
);
await configRepository.setString(
'VRCX_autoAcceptInviteRequests',
this.autoAcceptInviteRequests
);
};
$app.data.vrcRegistryAutoBackup = await configRepository.getBool(
'VRCX_vrcRegistryAutoBackup',

View File

@@ -231,7 +231,12 @@
"auto_state_change_active_or_busy": "Active / Busy",
"auto_state_change_join_me_or_ask_me": "Join Me / Ask Me",
"auto_state_change_join_me_or_busy": "Join Me / Busy",
"auto_state_change_ask_me_or_busy": "Ask Me / Busy"
"auto_state_change_ask_me_or_busy": "Ask Me / Busy",
"auto_invite_request_accept": "Auto Invite Request Accept",
"auto_invite_request_accept_tooltip": "Automatically accept Invite Requests from Favorite friends",
"auto_invite_request_accept_off": "Off",
"auto_invite_request_accept_favs": "All Favorites",
"auto_invite_request_accept_selected_favs": "Selected Favorites"
},
"legal_notice": {
"header": "Legal Notice",

View File

@@ -111,6 +111,11 @@ mixin settingsTab()
{ label: "Join Me or Busy", translationKey: "view.settings.general.automation.auto_state_change_join_me_or_busy" },
{ label: "Ask Me or Busy", translationKey: "view.settings.general.automation.auto_state_change_ask_me_or_busy" },
], "saveAutomationOptions")
+simpleRadioGroupWithTooltip("view.settings.general.automation.auto_invite_request_accept", "$t('view.settings.general.automation.auto_invite_request_accept_tooltip')", "autoAcceptInviteRequests", [
{ label: "Off", translationKey: "view.settings.general.automation.auto_invite_request_accept_off" },
{ label: "All Favorites", translationKey: "view.settings.general.automation.auto_invite_request_accept_favs" },
{ label: "Selected Favorites", translationKey: "view.settings.general.automation.auto_invite_request_accept_selected_favs" },
], "saveAutomationOptions")
//- General | Contributors
div.options-container
span.header {{ $t("view.settings.general.contributors.header" )}}