mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
Fix emoji and sticker saving
This commit is contained in:
@@ -1,4 +1,23 @@
|
|||||||
const inventoryReq = {
|
const inventoryReq = {
|
||||||
|
/**
|
||||||
|
* @param {{ inventoryId: string, userId: string }} params
|
||||||
|
* @returns {Promise<{json: any, params}>}
|
||||||
|
*/
|
||||||
|
getUserInventoryItem(params) {
|
||||||
|
return window.API.call(
|
||||||
|
`user/${params.userId}/inventory/${params.inventoryId}`,
|
||||||
|
{
|
||||||
|
method: 'GET'
|
||||||
|
}
|
||||||
|
).then((json) => {
|
||||||
|
const args = {
|
||||||
|
json,
|
||||||
|
params
|
||||||
|
};
|
||||||
|
return args;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{ inventoryId: string }} params
|
* @param {{ inventoryId: string }} params
|
||||||
* @returns {Promise<{json: any, params}>}
|
* @returns {Promise<{json: any, params}>}
|
||||||
|
|||||||
+30
-13
@@ -10919,6 +10919,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
|
|
||||||
$app.methods.trySaveStickerToFile = async function (
|
$app.methods.trySaveStickerToFile = async function (
|
||||||
displayName,
|
displayName,
|
||||||
|
userId,
|
||||||
inventoryId
|
inventoryId
|
||||||
) {
|
) {
|
||||||
if (this.instanceStickersCache.includes(inventoryId)) {
|
if (this.instanceStickersCache.includes(inventoryId)) {
|
||||||
@@ -10928,10 +10929,19 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
if (this.instanceStickersCache.size > 100) {
|
if (this.instanceStickersCache.size > 100) {
|
||||||
this.instanceStickersCache.shift();
|
this.instanceStickersCache.shift();
|
||||||
}
|
}
|
||||||
var args = await inventoryRequest.getInventoryItem({
|
var args = await inventoryRequest.getUserInventoryItem({
|
||||||
inventoryId
|
inventoryId,
|
||||||
|
userId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (
|
||||||
|
args.json.itemType !== 'sticker' ||
|
||||||
|
!args.json.flags.includes('ugc')
|
||||||
|
) {
|
||||||
|
// Not a sticker or ugc, skipping
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var imageUrl = args.json.metadata?.imageUrl ?? args.json.imageUrl;
|
var imageUrl = args.json.metadata?.imageUrl ?? args.json.imageUrl;
|
||||||
var createdAt = args.json.created_at;
|
var createdAt = args.json.created_at;
|
||||||
var monthFolder = createdAt.slice(0, 7);
|
var monthFolder = createdAt.slice(0, 7);
|
||||||
@@ -10958,8 +10968,11 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
$app.data.instanceInventoryQueue = [];
|
$app.data.instanceInventoryQueue = [];
|
||||||
$app.data.instanceInventoryQueueWorker = null;
|
$app.data.instanceInventoryQueueWorker = null;
|
||||||
|
|
||||||
$app.methods.queueCheckInstanceInventory = function (inventoryId) {
|
$app.methods.queueCheckInstanceInventory = function (inventoryId, userId) {
|
||||||
if (this.instanceInventoryCache.includes(inventoryId)) {
|
if (
|
||||||
|
this.instanceInventoryCache.includes(inventoryId) ||
|
||||||
|
this.instanceStickersCache.includes(inventoryId)
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.instanceInventoryCache.push(inventoryId);
|
this.instanceInventoryCache.push(inventoryId);
|
||||||
@@ -10967,25 +10980,29 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
this.instanceInventoryCache.shift();
|
this.instanceInventoryCache.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instanceInventoryQueue.push(inventoryId);
|
this.instanceInventoryQueue.push({ inventoryId, userId });
|
||||||
|
|
||||||
if (!this.instanceInventoryQueueWorker) {
|
if (!this.instanceInventoryQueueWorker) {
|
||||||
this.instanceInventoryQueueWorker = workerTimers.setInterval(() => {
|
this.instanceInventoryQueueWorker = workerTimers.setInterval(() => {
|
||||||
let inventoryId = this.instanceInventoryQueue.shift();
|
const item = this.instanceInventoryQueue.shift();
|
||||||
if (inventoryId) {
|
if (item?.inventoryId) {
|
||||||
this.trySaveEmojiToFile(inventoryId);
|
this.trySaveEmojiToFile(item.inventoryId, item.userId);
|
||||||
}
|
}
|
||||||
}, 2_500);
|
}, 2_500);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.trySaveEmojiToFile = async function (inventoryId) {
|
$app.methods.trySaveEmojiToFile = async function (inventoryId, userId) {
|
||||||
const args = await inventoryRequest.getInventoryItem({
|
const args = await inventoryRequest.getUserInventoryItem({
|
||||||
inventoryId
|
inventoryId,
|
||||||
|
userId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (args.json.itemType !== 'emoji') {
|
if (
|
||||||
// Not an emoji, skip
|
args.json.itemType !== 'emoji' ||
|
||||||
|
!args.json.flags.includes('ugc')
|
||||||
|
) {
|
||||||
|
// Not an emoji or ugc, skipping
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-6
@@ -283,16 +283,20 @@ export default class extends baseClass {
|
|||||||
|
|
||||||
if ($app.saveInstanceEmoji) {
|
if ($app.saveInstanceEmoji) {
|
||||||
try {
|
try {
|
||||||
// https://api.vrchat.cloud/api/1/inventory/spawn?id=inv_75781d65-92fe-4a80-a1ff-27ee6e843b08
|
// https://api.vrchat.cloud/api/1/user/usr_032383a7-748c-4fb2-94e4-bcb928e5de6b/inventory/inv_75781d65-92fe-4a80-a1ff-27ee6e843b08
|
||||||
const url = new URL(gameLog.url);
|
const url = new URL(gameLog.url);
|
||||||
if (
|
if (
|
||||||
url.pathname.substring(0, 22) ===
|
url.pathname.substring(0, 12) ===
|
||||||
'/api/1/inventory/spawn'
|
'/api/1/user/' &&
|
||||||
|
url.pathname.includes('/inventory/inv_')
|
||||||
) {
|
) {
|
||||||
const inventoryId = url.searchParams.get('id');
|
const pathArray = url.pathname.split('/');
|
||||||
if (inventoryId && inventoryId.length === 40) {
|
const userId = pathArray[4];
|
||||||
|
const inventoryId = pathArray[6];
|
||||||
|
if (userId && inventoryId.length === 40) {
|
||||||
$app.queueCheckInstanceInventory(
|
$app.queueCheckInstanceInventory(
|
||||||
inventoryId
|
inventoryId,
|
||||||
|
userId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -454,6 +458,7 @@ export default class extends baseClass {
|
|||||||
|
|
||||||
$app.trySaveStickerToFile(
|
$app.trySaveStickerToFile(
|
||||||
gameLog.displayName,
|
gameLog.displayName,
|
||||||
|
gameLog.userId,
|
||||||
gameLog.inventoryId
|
gameLog.inventoryId
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user