@lacrous/omnicloud 0.2.22 → 0.2.23

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 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.updateMany(
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",
@@ -2250,9 +2250,16 @@ var FolderService = class {
2250
2250
  );
2251
2251
  const engine = await this.engineFor(userId);
2252
2252
  const removedFileIds = [];
2253
+ const versionsByFile = await this.files.listVersionsForFiles(affected.map((file) => file.id));
2253
2254
  for (const file of affected) {
2254
2255
  try {
2255
- await engine.remove({ messageId: String(file.telegramMessageId) });
2256
+ const messageIds = /* @__PURE__ */ new Set([String(file.telegramMessageId)]);
2257
+ for (const version of versionsByFile.get(file.id) ?? []) {
2258
+ messageIds.add(String(version.telegramMessageId));
2259
+ }
2260
+ for (const messageId of messageIds) {
2261
+ await engine.remove({ messageId });
2262
+ }
2256
2263
  removedFileIds.push(file.id);
2257
2264
  } catch {
2258
2265
  }
@@ -2727,6 +2734,13 @@ function mapTelegramError(error, fallbackMessage) {
2727
2734
  case "CHANNEL_INVALID":
2728
2735
  case "CHAT_ID_INVALID":
2729
2736
  return new StorageNotInitializedError();
2737
+ // Permanent: the account cannot write to the channel. Retrying cannot help.
2738
+ case "CHAT_WRITE_FORBIDDEN":
2739
+ case "CHAT_ADMIN_REQUIRED":
2740
+ return new ForbiddenError("OmniCloud cannot write to the storage channel for this account");
2741
+ // Permanent: the stored channel reference is stale. Retrying with the same reference fails too.
2742
+ case "PEER_ID_INVALID":
2743
+ return new StorageNotInitializedError();
2730
2744
  case "MSG_ID_INVALID":
2731
2745
  case "MESSAGE_ID_INVALID":
2732
2746
  return new TelegramFileNotFoundError();