@lacrous/omnicloud 0.2.22 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +20 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/server/index.js +59 -10
package/dist/index.cjs
CHANGED
|
@@ -2177,11 +2177,11 @@ var FolderService = class {
|
|
|
2177
2177
|
const fileIds = await this.collectFileIds(userId, subtree);
|
|
2178
2178
|
const batchId = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2179
2179
|
const stampedAt = /* @__PURE__ */ new Date();
|
|
2180
|
-
await this.folders.
|
|
2180
|
+
await this.folders.trashSubtree(
|
|
2181
2181
|
subtree.map((folder) => folder.id),
|
|
2182
|
+
fileIds,
|
|
2182
2183
|
{ deletedAt: stampedAt, trashBatchId: batchId }
|
|
2183
2184
|
);
|
|
2184
|
-
await this.files.updateMany(fileIds, { deletedAt: stampedAt, trashBatchId: batchId });
|
|
2185
2185
|
await this.activity.record({
|
|
2186
2186
|
userId,
|
|
2187
2187
|
action: "trash",
|
|
@@ -2216,14 +2216,11 @@ var FolderService = class {
|
|
|
2216
2216
|
);
|
|
2217
2217
|
const restorableFileIds = restorableFiles.map((file) => file.id);
|
|
2218
2218
|
if (restorableFolders.length > 0) {
|
|
2219
|
-
await this.folders.
|
|
2219
|
+
await this.folders.restoreSubtree(
|
|
2220
2220
|
restorableFolders.map((folder) => folder.id),
|
|
2221
|
-
|
|
2221
|
+
restorableFileIds,
|
|
2222
|
+
{ rootId: id, reparent: { parentId } }
|
|
2222
2223
|
);
|
|
2223
|
-
await this.folders.update(id, { parentId });
|
|
2224
|
-
}
|
|
2225
|
-
if (restorableFileIds.length > 0) {
|
|
2226
|
-
await this.files.updateMany(restorableFileIds, { deletedAt: null, trashBatchId: null });
|
|
2227
2224
|
}
|
|
2228
2225
|
await this.activity.record({
|
|
2229
2226
|
userId,
|
|
@@ -2250,9 +2247,16 @@ var FolderService = class {
|
|
|
2250
2247
|
);
|
|
2251
2248
|
const engine = await this.engineFor(userId);
|
|
2252
2249
|
const removedFileIds = [];
|
|
2250
|
+
const versionsByFile = await this.files.listVersionsForFiles(affected.map((file) => file.id));
|
|
2253
2251
|
for (const file of affected) {
|
|
2254
2252
|
try {
|
|
2255
|
-
|
|
2253
|
+
const messageIds = /* @__PURE__ */ new Set([String(file.telegramMessageId)]);
|
|
2254
|
+
for (const version of versionsByFile.get(file.id) ?? []) {
|
|
2255
|
+
messageIds.add(String(version.telegramMessageId));
|
|
2256
|
+
}
|
|
2257
|
+
for (const messageId of messageIds) {
|
|
2258
|
+
await engine.remove({ messageId });
|
|
2259
|
+
}
|
|
2256
2260
|
removedFileIds.push(file.id);
|
|
2257
2261
|
} catch {
|
|
2258
2262
|
}
|
|
@@ -2727,6 +2731,13 @@ function mapTelegramError(error, fallbackMessage) {
|
|
|
2727
2731
|
case "CHANNEL_INVALID":
|
|
2728
2732
|
case "CHAT_ID_INVALID":
|
|
2729
2733
|
return new StorageNotInitializedError();
|
|
2734
|
+
// Permanent: the account cannot write to the channel. Retrying cannot help.
|
|
2735
|
+
case "CHAT_WRITE_FORBIDDEN":
|
|
2736
|
+
case "CHAT_ADMIN_REQUIRED":
|
|
2737
|
+
return new ForbiddenError("OmniCloud cannot write to the storage channel for this account");
|
|
2738
|
+
// Permanent: the stored channel reference is stale. Retrying with the same reference fails too.
|
|
2739
|
+
case "PEER_ID_INVALID":
|
|
2740
|
+
return new StorageNotInitializedError();
|
|
2730
2741
|
case "MSG_ID_INVALID":
|
|
2731
2742
|
case "MESSAGE_ID_INVALID":
|
|
2732
2743
|
return new TelegramFileNotFoundError();
|