mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-05 14:26:06 +02:00
Fix saving instance stickers
This commit is contained in:
+14
-8
@@ -1341,25 +1341,31 @@ namespace VRCX
|
||||
|
||||
private bool ParseStickerSpawn(FileInfo fileInfo, LogContext logContext, string line, int offset)
|
||||
{
|
||||
// [StickersManager] User usr_032383a7-748c-4fb2-94e4-bcb928e5de6b (Natsumi-sama) spawned sticker inv_8b380ee4-9a8a-484e-a0c3-b01290b92c6a
|
||||
var index = line.IndexOf("[StickersManager] User ", StringComparison.Ordinal);
|
||||
if (index == -1 || !line.Contains("file_") || !line.Contains("spawned sticker"))
|
||||
if (index == -1 || !line.Contains("inv_") || !line.Contains("spawned sticker"))
|
||||
return false;
|
||||
|
||||
string info = line.Substring(index + 23);
|
||||
var info = line.Substring(index + 23);
|
||||
|
||||
var (userId, displayName) = ParseUserInfo(info);
|
||||
var (userId, displayName) = ParseUserInfo(info); // it's flipped
|
||||
if (string.IsNullOrEmpty(displayName) && string.IsNullOrEmpty(userId))
|
||||
{
|
||||
logger.Warn("Failed to parse user info from log line: {0}", line);
|
||||
return true;
|
||||
}
|
||||
|
||||
var fileIdIndex = info.IndexOf("file_", StringComparison.Ordinal);
|
||||
string fileId = info.Substring(fileIdIndex);
|
||||
var inventoryIdIndex = info.IndexOf("inv_", StringComparison.Ordinal);
|
||||
var inventoryId = info.Substring(inventoryIdIndex);
|
||||
|
||||
AppendLog(new[]
|
||||
{
|
||||
fileInfo.Name,
|
||||
ConvertLogTimeToISO8601(line),
|
||||
"sticker-spawn",
|
||||
userId,
|
||||
displayName,
|
||||
fileId,
|
||||
userId ?? string.Empty,
|
||||
displayName ?? string.Empty,
|
||||
inventoryId
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
+21
-13
@@ -10918,23 +10918,31 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
});
|
||||
|
||||
$app.data.stickersCache = [];
|
||||
$app.data.instanceStickersCache = [];
|
||||
|
||||
$app.methods.trySaveStickerToFile = async function (displayName, fileId) {
|
||||
if ($app.stickersCache.includes(fileId)) return;
|
||||
$app.stickersCache.push(fileId);
|
||||
if ($app.stickersCache.size > 100) {
|
||||
$app.stickersCache.shift();
|
||||
$app.methods.trySaveStickerToFile = async function (
|
||||
displayName,
|
||||
inventoryId
|
||||
) {
|
||||
if (this.instanceStickersCache.includes(inventoryId)) {
|
||||
return;
|
||||
}
|
||||
var args = await API.call(`file/${fileId}`);
|
||||
var imageUrl = args.versions[1].file.url;
|
||||
var createdAt = args.versions[0].created_at;
|
||||
this.instanceStickersCache.push(inventoryId);
|
||||
if (this.instanceStickersCache.size > 100) {
|
||||
this.instanceStickersCache.shift();
|
||||
}
|
||||
var args = await inventoryRequest.getInventoryItem({
|
||||
inventoryId
|
||||
});
|
||||
|
||||
var imageUrl = args.json.metadata?.imageUrl ?? args.json.imageUrl;
|
||||
var createdAt = args.json.created_at;
|
||||
var monthFolder = createdAt.slice(0, 7);
|
||||
var fileNameDate = createdAt
|
||||
.replace(/:/g, '-')
|
||||
.replace(/T/g, '_')
|
||||
.replace(/Z/g, '');
|
||||
var fileName = `${displayName}_${fileNameDate}_${fileId}.png`;
|
||||
var fileName = `${displayName}_${fileNameDate}_${inventoryId}.png`;
|
||||
var filePath = await AppApi.SaveStickerToFile(
|
||||
imageUrl,
|
||||
this.ugcFolderPath,
|
||||
@@ -11032,7 +11040,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
|
||||
$app.data.printCache = [];
|
||||
$app.data.printQueue = [];
|
||||
$app.data.printQueueWorker = undefined;
|
||||
$app.data.printQueueWorker = null;
|
||||
|
||||
$app.methods.queueSavePrintToFile = function (printId) {
|
||||
if (this.printCache.includes(printId)) {
|
||||
@@ -11091,9 +11099,9 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.printQueue.length == 0) {
|
||||
if (this.printQueue.length === 0) {
|
||||
workerTimers.clearInterval(this.printQueueWorker);
|
||||
this.printQueueWorker = undefined;
|
||||
this.printQueueWorker = null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -430,7 +430,7 @@ export default class extends baseClass {
|
||||
|
||||
$app.trySaveStickerToFile(
|
||||
gameLog.displayName,
|
||||
gameLog.fileId
|
||||
gameLog.inventoryId
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -539,6 +539,8 @@ export default class extends baseClass {
|
||||
) {
|
||||
$app.refreshEmojiTable();
|
||||
}
|
||||
} else if (contentType === 'sticker') {
|
||||
// on sticker upload
|
||||
} else if (contentType === 'print') {
|
||||
if (
|
||||
$app.autoDeleteOldPrints &&
|
||||
|
||||
@@ -90,7 +90,7 @@ class GameLogService {
|
||||
case 'sticker-spawn':
|
||||
gameLog.userId = args[0];
|
||||
gameLog.displayName = args[1];
|
||||
gameLog.fileId = args[2];
|
||||
gameLog.inventoryId = args[2];
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user