mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-29 11:43:48 +02:00
refactor: Splitting API requests from app.js (#1175)
This commit is contained in:
@@ -2,7 +2,7 @@ import * as workerTimers from 'worker-timers';
|
||||
import configRepository from '../repository/config.js';
|
||||
import database from '../repository/database.js';
|
||||
import { baseClass, $app, API, $t, $utils } from './baseClass.js';
|
||||
import { avatarRequest, worldRequest } from './request';
|
||||
import { avatarRequest, favoriteRequest, worldRequest } from './request';
|
||||
|
||||
export default class extends baseClass {
|
||||
constructor(_app, _API, _t) {
|
||||
@@ -317,20 +317,22 @@ export default class extends baseClass {
|
||||
),
|
||||
callback: (action, instance) => {
|
||||
if (action === 'confirm') {
|
||||
API.saveFavoriteGroup({
|
||||
type: ctx.type,
|
||||
group: ctx.name,
|
||||
displayName: instance.inputValue
|
||||
}).then((args) => {
|
||||
this.$message({
|
||||
message: $t(
|
||||
'prompt.change_favorite_group_name.message.success'
|
||||
),
|
||||
type: 'success'
|
||||
favoriteRequest
|
||||
.saveFavoriteGroup({
|
||||
type: ctx.type,
|
||||
group: ctx.name,
|
||||
displayName: instance.inputValue
|
||||
})
|
||||
.then((args) => {
|
||||
this.$message({
|
||||
message: $t(
|
||||
'prompt.change_favorite_group_name.message.success'
|
||||
),
|
||||
type: 'success'
|
||||
});
|
||||
// load new group name
|
||||
API.refreshFavoriteGroups();
|
||||
});
|
||||
// load new group name
|
||||
API.refreshFavoriteGroups();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
src/classes/request/avatarModeration.js
Normal file
60
src/classes/request/avatarModeration.js
Normal file
@@ -0,0 +1,60 @@
|
||||
// #region | API: AvatarModeration
|
||||
|
||||
const avatarModerationReq = {
|
||||
getAvatarModerations() {
|
||||
return window.API.call('auth/user/avatarmoderations', {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
window.API.$emit('AVATAR-MODERATION:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ avatarModerationType: string, targetAvatarId: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
sendAvatarModeration(params) {
|
||||
return window.API.call('auth/user/avatarmoderations', {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATAR-MODERATION', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ avatarModerationType: string, targetAvatarId: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
deleteAvatarModeration(params) {
|
||||
return window.API.call(
|
||||
`auth/user/avatarmoderations?targetAvatarId=${encodeURIComponent(
|
||||
params.targetAvatarId
|
||||
)}&avatarModerationType=${encodeURIComponent(
|
||||
params.avatarModerationType
|
||||
)}`,
|
||||
{
|
||||
method: 'DELETE'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATAR-MODERATION:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
export default avatarModerationReq;
|
||||
187
src/classes/request/favorite.js
Normal file
187
src/classes/request/favorite.js
Normal file
@@ -0,0 +1,187 @@
|
||||
// #region | API: Favorite
|
||||
|
||||
const favoriteReq = {
|
||||
getFavoriteLimits() {
|
||||
return window.API.call('auth/user/favoritelimits', {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
window.API.$emit('FAVORITE:LIMITS', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* n: number,
|
||||
* offset: number,
|
||||
* type: string,
|
||||
* tag: string
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFavorites(params) {
|
||||
return window.API.call('favorites', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* type: string,
|
||||
* favoriteId: string (objectId),
|
||||
* tags: string
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
addFavorite(params) {
|
||||
return window.API.call('favorites', {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:ADD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ objectId: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
deleteFavorite(params) {
|
||||
return window.API.call(`favorites/${params.objectId}`, {
|
||||
method: 'DELETE'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ n: number, offset: number, type: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFavoriteGroups(params) {
|
||||
return window.API.call('favorite/groups', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:GROUP:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {{ type: string, group: string, displayName: string, visibility: string }} params group is a name
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
saveFavoriteGroup(params) {
|
||||
return window.API.call(
|
||||
`favorite/group/${params.type}/${params.group}/${window.API.currentUser.id}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:GROUP:SAVE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* type: string,
|
||||
* group: string (name)
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
clearFavoriteGroup(params) {
|
||||
return window.API.call(
|
||||
`favorite/group/${params.type}/${params.group}/${window.API.currentUser.id}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
params
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:GROUP:CLEAR', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* n: number,
|
||||
* offset: number
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFavoriteWorlds(params) {
|
||||
return window.API.call('worlds/favorites', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:WORLD:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* n: number,
|
||||
* offset: number
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFavoriteAvatars(params) {
|
||||
return window.API.call('avatars/favorites', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:AVATAR:LIST', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
export default favoriteReq;
|
||||
306
src/classes/request/image.js
Normal file
306
src/classes/request/image.js
Normal file
@@ -0,0 +1,306 @@
|
||||
const imageReq = {
|
||||
// use in uploadAvatarImage
|
||||
// need to test
|
||||
async uploadAvatarFailCleanup(id) {
|
||||
const json = await window.API.call(`file/${id}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
const fileId = json.id;
|
||||
const fileVersion = json.versions[json.versions.length - 1].version;
|
||||
window.API.call(`file/${fileId}/${fileVersion}/signature/finish`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
window.API.call(`file/${fileId}/${fileVersion}/file/finish`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
window.$app.avatarDialog.loading = false;
|
||||
window.$app.changeAvatarImageDialogLoading = false;
|
||||
},
|
||||
|
||||
async uploadAvatarImage(params, fileId) {
|
||||
try {
|
||||
return await window.API.call(`file/${fileId}`, {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params,
|
||||
fileId
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:INIT', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadAvatarFailCleanup(fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
async uploadAvatarImageFileStart(params) {
|
||||
try {
|
||||
return await window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/file/start`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:FILESTART', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadAvatarFailCleanup(params.fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
uploadAvatarImageFileFinish(params) {
|
||||
return window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/file/finish`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
maxParts: 0,
|
||||
nextPartNumber: 0
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:FILEFINISH', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
async uploadAvatarImageSigStart(params) {
|
||||
try {
|
||||
return await window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/signature/start`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:SIGSTART', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadAvatarFailCleanup(params.fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
uploadAvatarImageSigFinish(params) {
|
||||
return window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/signature/finish`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
maxParts: 0,
|
||||
nextPartNumber: 0
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:SIGFINISH', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
setAvatarImage(params) {
|
||||
return window.API.call(`avatars/${params.id}`, {
|
||||
method: 'PUT',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:SET', args);
|
||||
window.API.$emit('AVATAR', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
// use in uploadWorldImage
|
||||
// need to test
|
||||
async uploadWorldFailCleanup(id) {
|
||||
const json = await window.API.call(`file/${id}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
const fileId = json.id;
|
||||
const fileVersion = json.versions[json.versions.length - 1].version;
|
||||
window.API.call(`file/${fileId}/${fileVersion}/signature/finish`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
window.API.call(`file/${fileId}/${fileVersion}/file/finish`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
window.$app.worldDialog.loading = false;
|
||||
window.$app.changeWorldImageDialogLoading = false;
|
||||
},
|
||||
|
||||
async uploadWorldImage(params, fileId) {
|
||||
try {
|
||||
return await window.API.call(`file/${fileId}`, {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params,
|
||||
fileId
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:INIT', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadWorldFailCleanup(fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
async uploadWorldImageFileStart(params) {
|
||||
try {
|
||||
return await window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/file/start`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:FILESTART', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadWorldFailCleanup(params.fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
uploadWorldImageFileFinish(params) {
|
||||
return window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/file/finish`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
maxParts: 0,
|
||||
nextPartNumber: 0
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:FILEFINISH', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
async uploadWorldImageSigStart(params) {
|
||||
try {
|
||||
return await window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/signature/start`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:SIGSTART', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadWorldFailCleanup(params.fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
uploadWorldImageSigFinish(params) {
|
||||
return window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/signature/finish`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
maxParts: 0,
|
||||
nextPartNumber: 0
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:SIGFINISH', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
setWorldImage(params) {
|
||||
return window.API.call(`worlds/${params.id}`, {
|
||||
method: 'PUT',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:SET', args);
|
||||
window.API.$emit('WORLD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getAvatarImages(params) {
|
||||
return window.API.call(`file/${params.fileId}`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:GET', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getWorldImages(params) {
|
||||
return window.API.call(`file/${params.fileId}`, {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:GET', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default imageReq;
|
||||
@@ -12,6 +12,14 @@ import instanceRequest from './instance';
|
||||
import friendRequest from './friend';
|
||||
import avatarRequest from './avatar';
|
||||
import notificationRequest from './notification';
|
||||
import playerModerationRequest from './playerModeration';
|
||||
import avatarModerationRequest from './avatarModeration';
|
||||
import favoriteRequest from './favorite';
|
||||
import vrcPlusIconRequest from './vrcPlusIcon';
|
||||
import vrcPlusImageRequest from './vrcPlusImage';
|
||||
import inviteMessagesRequest from './inviteMessages';
|
||||
import imageRequest from './image';
|
||||
import miscRequest from './misc';
|
||||
|
||||
export {
|
||||
userRequest,
|
||||
@@ -19,5 +27,13 @@ export {
|
||||
instanceRequest,
|
||||
friendRequest,
|
||||
avatarRequest,
|
||||
notificationRequest
|
||||
notificationRequest,
|
||||
playerModerationRequest,
|
||||
avatarModerationRequest,
|
||||
favoriteRequest,
|
||||
vrcPlusIconRequest,
|
||||
vrcPlusImageRequest,
|
||||
inviteMessagesRequest,
|
||||
imageRequest,
|
||||
miscRequest
|
||||
};
|
||||
|
||||
41
src/classes/request/inviteMessages.js
Normal file
41
src/classes/request/inviteMessages.js
Normal file
@@ -0,0 +1,41 @@
|
||||
// #region | App: Invite Messages
|
||||
|
||||
const inviteMessagesReq = {
|
||||
refreshInviteMessageTableData(messageType) {
|
||||
return window.API.call(
|
||||
`message/${window.API.currentUser.id}/${messageType}`,
|
||||
{
|
||||
method: 'GET'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
messageType
|
||||
};
|
||||
window.API.$emit(`INVITE:${messageType.toUpperCase()}`, args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
editInviteMessage(params, messageType, slot) {
|
||||
return window.API.call(
|
||||
`message/${window.API.currentUser.id}/${messageType}/${slot}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params,
|
||||
messageType,
|
||||
slot
|
||||
};
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
export default inviteMessagesReq;
|
||||
179
src/classes/request/misc.js
Normal file
179
src/classes/request/misc.js
Normal file
@@ -0,0 +1,179 @@
|
||||
const miscReq = {
|
||||
getBundles(fileId) {
|
||||
return window.API.call(`file/${fileId}`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
saveNote(params) {
|
||||
return window.API.call('userNotes', {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('NOTE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* userId: string,
|
||||
* contentType: string,
|
||||
* reason: string,
|
||||
* type: string
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
reportUser(params) {
|
||||
return window.API.call(`feedback/${params.userId}/user`, {
|
||||
method: 'POST',
|
||||
params: {
|
||||
contentType: params.contentType,
|
||||
reason: params.reason,
|
||||
type: params.type
|
||||
}
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FEEDBACK:REPORT:USER', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* fileId: string,
|
||||
* version: number
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFileAnalysis(params) {
|
||||
return window.API.call(
|
||||
`analysis/${params.fileId}/${params.version}/${params.variant}`,
|
||||
{
|
||||
method: 'GET'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FILE:ANALYSIS', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getVRChatCredits() {
|
||||
return window.API.call(`user/${window.API.currentUser.id}/balance`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
window.API.$emit('VRCCREDITS', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* location: string,
|
||||
* hardClose: boolean
|
||||
* }} params
|
||||
* @returns {Promise<{json: any, params}>}
|
||||
*/
|
||||
closeInstance(params) {
|
||||
return window.API.call(`instances/${params.location}`, {
|
||||
method: 'DELETE',
|
||||
params: {
|
||||
hardClose: params.hardClose ?? false
|
||||
}
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('INSTANCE:CLOSE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* worldId: string
|
||||
* }} params
|
||||
* @returns {Promise<{json: any, params}>}
|
||||
*/
|
||||
deleteWorldPersistData(params) {
|
||||
return window.API.call(
|
||||
`users/${window.API.currentUser.id}/${params.worldId}/persist`,
|
||||
{
|
||||
method: 'DELETE'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLD:PERSIST:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* worldId: string
|
||||
* }} params
|
||||
* @returns {Promise<{json: any, params}>}
|
||||
*/
|
||||
hasWorldPersistData(params) {
|
||||
return window.API.call(
|
||||
`users/${window.API.currentUser.id}/${params.worldId}/persist/exists`,
|
||||
{
|
||||
method: 'GET'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLD:PERSIST:HAS', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
updateBadge(params) {
|
||||
return window.API.call(
|
||||
`users/${window.API.currentUser.id}/badges/${params.badgeId}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
userId: window.API.currentUser.id,
|
||||
badgeId: params.badgeId,
|
||||
hidden: params.hidden,
|
||||
showcased: params.showcased
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('BADGE:UPDATE', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default miscReq;
|
||||
56
src/classes/request/playerModeration.js
Normal file
56
src/classes/request/playerModeration.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// #region | API: PlayerModeration
|
||||
|
||||
const playerModerationReq = {
|
||||
getPlayerModerations() {
|
||||
return window.API.call('auth/user/playermoderations', {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
window.API.$emit('PLAYER-MODERATION:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ moderated: string, type: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
// old-way: POST auth/user/blocks {blocked:userId}
|
||||
sendPlayerModeration(params) {
|
||||
return window.API.call('auth/user/playermoderations', {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PLAYER-MODERATION:SEND', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ moderated: string, type: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
// old-way: PUT auth/user/unblocks {blocked:userId}
|
||||
deletePlayerModeration(params) {
|
||||
return window.API.call('auth/user/unplayermoderate', {
|
||||
method: 'PUT',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PLAYER-MODERATION:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
export default playerModerationReq;
|
||||
66
src/classes/request/vrcPlusIcon.js
Normal file
66
src/classes/request/vrcPlusIcon.js
Normal file
@@ -0,0 +1,66 @@
|
||||
// #region | App: VRCPlus Icons
|
||||
|
||||
const VRCPlusIconsReq = {
|
||||
getFileList(params) {
|
||||
return window.API.call('files', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FILES:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
deleteFile(fileId) {
|
||||
return window.API.call(`file/${fileId}`, {
|
||||
method: 'DELETE'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
fileId
|
||||
};
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
uploadVRCPlusIcon(imageData) {
|
||||
const params = {
|
||||
tag: 'icon'
|
||||
};
|
||||
return window.API.call('file/image', {
|
||||
uploadImage: true,
|
||||
matchingDimensions: true,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('VRCPLUSICON:ADD', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
|
||||
// unused
|
||||
// images.pug line 63
|
||||
// deleteFileVersion(params) {
|
||||
// return window.API.call(`file/${params.fileId}/${params.version}`, {
|
||||
// method: 'DELETE'
|
||||
// }).then((json) => {
|
||||
// const args = {
|
||||
// json,
|
||||
// params
|
||||
// };
|
||||
// return args;
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
export default VRCPlusIconsReq;
|
||||
125
src/classes/request/vrcPlusImage.js
Normal file
125
src/classes/request/vrcPlusImage.js
Normal file
@@ -0,0 +1,125 @@
|
||||
const vrcPlusImageReq = {
|
||||
uploadGalleryImage(imageData) {
|
||||
const params = {
|
||||
tag: 'gallery'
|
||||
};
|
||||
return window.API.call('file/image', {
|
||||
uploadImage: true,
|
||||
matchingDimensions: false,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('GALLERYIMAGE:ADD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
uploadSticker(imageData, params) {
|
||||
return window.API.call('file/image', {
|
||||
uploadImage: true,
|
||||
matchingDimensions: true,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('STICKER:ADD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getPrints(params) {
|
||||
return window.API.call(`prints/user/${window.API.currentUser.id}`, {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PRINT:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
deletePrint(printId) {
|
||||
return window.API.call(`prints/${printId}`, {
|
||||
method: 'DELETE'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
printId
|
||||
};
|
||||
window.API.$emit('PRINT:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
uploadPrint(imageData, params) {
|
||||
return window.API.call('prints', {
|
||||
uploadImagePrint: true,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PRINT:ADD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getPrint(params) {
|
||||
return window.API.call(`prints/${params.printId}`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PRINT', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
uploadEmoji(imageData, params) {
|
||||
return window.API.call('file/image', {
|
||||
uploadImage: true,
|
||||
matchingDimensions: true,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('EMOJI:ADD', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
|
||||
// ----------- no place uses this function ------------
|
||||
|
||||
// editPrint(params) {
|
||||
// return window.API.call(`prints/${params.printId}`, {
|
||||
// method: 'POST',
|
||||
// params
|
||||
// }).then((json) => {
|
||||
// const args = {
|
||||
// json,
|
||||
// params
|
||||
// };
|
||||
// window.API.$emit('PRINT:EDIT', args);
|
||||
// return args;
|
||||
// });
|
||||
// },
|
||||
};
|
||||
|
||||
export default vrcPlusImageReq;
|
||||
@@ -205,7 +205,7 @@ export default class extends baseClass {
|
||||
'<el-tooltip v-if="isValidInstance" placement="bottom">' +
|
||||
'<div slot="content">' +
|
||||
'<template v-if="isClosed"><span>Closed At: {{ closedAt | formatDate(\'long\') }}</span></br></template>' +
|
||||
'<template v-if="canCloseInstance"><el-button :disabled="isClosed" size="mini" type="primary" @click="$app.closeInstance(location)">{{ $t("dialog.user.info.close_instance") }}</el-button></br></br></template>' +
|
||||
'<template v-if="canCloseInstance"><el-button :disabled="isClosed" size="mini" type="primary" @click="$root.closeInstance(location)">{{ $t("dialog.user.info.close_instance") }}</el-button></br></br></template>' +
|
||||
'<span><span style="color:#409eff">PC: </span>{{ platforms.standalonewindows }}</span></br>' +
|
||||
'<span><span style="color:#67c23a">Android: </span>{{ platforms.android }}</span></br>' +
|
||||
'<span>{{ $t("dialog.user.info.instance_game_version") }} {{ gameServerVersion }}</span></br>' +
|
||||
|
||||
Reference in New Issue
Block a user