Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Feature] Implement Auto Accept Invite Request #797

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4859,6 +4859,12 @@ speechSynthesis.getVoices();
notificationId: content.id
}
});
this.$emit('PIPELINE:NOTIFICATION', {
json: content,
params: {
notificationId: content.id
}
});
break;

case 'notification-v2':
Expand Down Expand Up @@ -5486,6 +5492,7 @@ speechSynthesis.getVoices();
nextClearVRCXCacheCheck: 0,
nextDiscordUpdate: 0,
nextAutoStateChange: 0,
autoAcceptInviteRequests: 'Off',
isDiscordActive: false,
isGameRunning: false,
isGameNoVR: true,
Expand Down Expand Up @@ -14794,6 +14801,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 @@ -15628,11 +15690,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