Skip to content

Commit

Permalink
Implement Auto Accept Invite Request (vrcx-team#797)
Browse files Browse the repository at this point in the history
Implementation for Auto Accepting of Invite Requests with multiple settings.
Off / All Favorites / Selected Favorites
  • Loading branch information
Nekromateion authored and Natsumi-sama committed May 28, 2024
1 parent e73f032 commit a3a3ec8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
70 changes: 70 additions & 0 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4856,6 +4856,12 @@ speechSynthesis.getVoices();
notificationId: content.id
}
});
this.$emit('PIPELINE:NOTIFICATION', {
json: content,
params: {
notificationId: content.id
}
});
break;

case 'notification-v2':
Expand Down Expand Up @@ -5483,6 +5489,7 @@ speechSynthesis.getVoices();
nextClearVRCXCacheCheck: 0,
nextDiscordUpdate: 0,
nextAutoStateChange: 0,
autoAcceptInviteRequests: 'Off',
isDiscordActive: false,
isGameRunning: false,
isGameNoVR: true,
Expand Down Expand Up @@ -14790,6 +14797,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) {
Expand Down Expand Up @@ -15624,11 +15686,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',
Expand Down
7 changes: 6 additions & 1 deletion html/src/localization/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions html/src/mixins/tabs/settings.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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" )}}
Expand Down

0 comments on commit a3a3ec8

Please sign in to comment.