Change invite params to new format

This commit is contained in:
Natsumi
2021-02-07 19:24:41 +13:00
parent bebff062ae
commit 663b9feab6

View File

@@ -710,16 +710,6 @@ speechSynthesis.getVoices();
API.getCachedWorld({ API.getCachedWorld({
worldId: L.worldId worldId: L.worldId
}).then((args) => { }).then((args) => {
var params = {
receiverUserId: API.currentUser.id,
type: 'invite',
message: '',
seen: false,
details: {
worldId: L.tag,
worldName: args.ref.name
}
};
if (API.currentUser.status === 'busy') { if (API.currentUser.status === 'busy') {
this.$message({ this.$message({
message: 'You can\'t invite yourself in \'Do Not Disturb\' mode', message: 'You can\'t invite yourself in \'Do Not Disturb\' mode',
@@ -727,7 +717,11 @@ speechSynthesis.getVoices();
}); });
return; return;
} }
API.sendNotification(params).finally(() => { API.sendInvite({
instanceId: L.tag,
worldId: L.tag,
worldName: args.ref.name
}, API.currentUser.id).finally(() => {
this.$message({ this.$message({
message: 'Invite sent to yourself', message: 'Invite sent to yourself',
type: 'success' type: 'success'
@@ -2064,8 +2058,9 @@ speechSynthesis.getVoices();
details: json-string details: json-string
} }
*/ */
API.sendNotification = function (params) {
return this.call(`user/${params.receiverUserId}/notification`, { API.sendInvite = function (params, receiverUserId) {
return this.call(`invite/${receiverUserId}`, {
method: 'POST', method: 'POST',
params params
}).then((json) => { }).then((json) => {
@@ -2073,7 +2068,21 @@ speechSynthesis.getVoices();
json, json,
params params
}; };
this.$emit('NOTIFICATION:SEND', args); this.$emit('NOTIFICATION:INVITE:SEND', args);
return args;
});
};
API.sendRequestInvite = function (params, receiverUserId) {
return this.call(`requestInvite/${receiverUserId}`, {
method: 'POST',
params
}).then((json) => {
var args = {
json,
params
};
this.$emit('NOTIFICATION:REQUESTINVITE:SEND', args);
return args; return args;
}); });
}; };
@@ -6917,15 +6926,11 @@ speechSynthesis.getVoices();
} else if (command === 'Logout') { } else if (command === 'Logout') {
this.logout(); this.logout();
} else if (command === 'Request Invite') { } else if (command === 'Request Invite') {
API.sendNotification({ API.sendRequestInvite({
receiverUserId: D.id,
type: 'requestInvite',
message: '',
seen: false,
details: { details: {
platform: 'standalonewindows' platform: 'standalonewindows'
} }
}).then((args) => { }, D.id).then((args) => {
this.$message('Request invite sent'); this.$message('Request invite sent');
return args; return args;
}); });
@@ -6934,16 +6939,11 @@ speechSynthesis.getVoices();
API.getCachedWorld({ API.getCachedWorld({
worldId: L.worldId worldId: L.worldId
}).then((args) => { }).then((args) => {
API.sendNotification({ API.sendInvite({
receiverUserId: D.id, instanceId: this.lastLocation,
type: 'invite',
message: '',
seen: false,
details: {
worldId: this.lastLocation, worldId: this.lastLocation,
worldName: args.ref.name worldName: args.ref.name
} }, D.id).then((_args) => {
}).then((_args) => {
this.$message('Invite sent'); this.$message('Invite sent');
return _args; return _args;
}); });
@@ -7626,20 +7626,14 @@ speechSynthesis.getVoices();
return; return;
} }
D.loading = true; D.loading = true;
var params = {
receiverUserId: '',
type: 'invite',
message: '',
seen: false,
details: {
worldId: D.worldId,
worldName: D.worldName
}
};
var inviteLoop = () => { var inviteLoop = () => {
if (D.userIds.length > 0) { if (D.userIds.length > 0) {
params.receiverUserId = D.userIds.shift(); var receiverUserId = D.userIds.shift();
API.sendNotification(params).finally(inviteLoop); API.sendInvite({
instanceId: D.worldId,
worldId: D.worldId,
worldName: D.worldName
}, receiverUserId).finally(inviteLoop);
} else { } else {
D.loading = false; D.loading = false;
D.visible = false; D.visible = false;