@social-mail/social-mail-web-server 1.7.721 → 1.7.723

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.7.721",
3
+ "version": "1.7.723",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@aws-sdk/client-s3": "^3.717.0",
23
23
  "@azure/storage-blob": "^12.25.0",
24
- "@entity-access/entity-access": "^1.0.481",
24
+ "@entity-access/entity-access": "^1.0.482",
25
25
  "@entity-access/server-pages": "^1.1.470",
26
26
  "@peculiar/asn1-schema": "^2.3.15",
27
27
  "@social-mail/shared": "^1.0.29",
@@ -15,6 +15,7 @@ import WorkflowContext from "@entity-access/entity-access/dist/workflows/Workflo
15
15
  import CopyTemplateWorkflow from "../../workflows/site/CopyTemplateWorkflow.js";
16
16
  import DeleteWebsiteWorkflow from "../../workflows/web-site/DeleteWebSiteWorkflow.js";
17
17
  import WebSiteVersionService from "../../services/files/WebSiteVersionService.js";
18
+ import { hash } from "crypto";
18
19
 
19
20
  export default class WebSiteEvents extends AuthenticatedEvents<WebSite> {
20
21
 
@@ -99,9 +100,13 @@ export default class WebSiteEvents extends AuthenticatedEvents<WebSite> {
99
100
 
100
101
  async copyTemplate(entity: WebSite) {
101
102
 
103
+ const { folderID, templateID } = entity;
104
+
102
105
  await this.context.queue(CopyTemplateWorkflow, {
103
- folderID: entity.folderID,
104
- templateID: entity.templateID
106
+ folderID,
107
+ templateID
108
+ }, {
109
+ id: `copy-template-${folderID}-${ hash("sha256", `${templateID}` as any, "hex")}`
105
110
  });
106
111
 
107
112
  }
@@ -175,7 +175,7 @@ export default class AppTempFileService {
175
175
 
176
176
  async downloadFile(folder: AppTempFile, url: string, path: string, transform: {[key: string]: string}) {
177
177
  const { base: name } = parse(path);
178
- let localFile = await this.tfs.download(url, name);
178
+ let localFile = await this.tfs.download(url, name, 3);
179
179
 
180
180
  // if transform
181
181
  // do the transform here...
@@ -146,17 +146,24 @@ export default class TempFileService {
146
146
  return lf;
147
147
  }
148
148
 
149
- public async download(inputUrl: string, name?: string) {
149
+ public async download(inputUrl: string, name?: string, retry = 1) {
150
150
 
151
- const parsedUrl = url.parse(inputUrl);
152
- const urlFilePath = parsedUrl.path;
153
- const fileInfo = path.parse(urlFilePath);
154
- if (name && !name.endsWith(fileInfo.ext)) {
155
- name += fileInfo.ext;
151
+ try {
152
+ const parsedUrl = url.parse(inputUrl);
153
+ const urlFilePath = parsedUrl.path;
154
+ const fileInfo = path.parse(urlFilePath);
155
+ if (name && !name.endsWith(fileInfo.ext)) {
156
+ name += fileInfo.ext;
157
+ }
158
+ const t = await this.createTempFile(fileInfo.ext, name);
159
+ await this.fetch(inputUrl, t.path);
160
+ return t;
161
+ } catch (error) {
162
+ if(--retry) {
163
+ return this.download(inputUrl, name, retry);
164
+ }
165
+ throw error;
156
166
  }
157
- const t = await this.createTempFile(fileInfo.ext, name);
158
- await this.fetch(inputUrl, t.path);
159
- return t;
160
167
  }
161
168
 
162
169
  public async createFrom(fileName: string, content: Buffer | Stream, contentType: string) {