@social-mail/social-mail-web-server 1.9.25 → 1.9.27
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/server/services/files/SnapshotService.d.ts +2 -0
- package/dist/server/services/files/SnapshotService.d.ts.map +1 -1
- package/dist/server/services/files/SnapshotService.js +19 -0
- package/dist/server/services/files/SnapshotService.js.map +1 -1
- package/dist/server/services/files/WebSiteContentService.d.ts +1 -0
- package/dist/server/services/files/WebSiteContentService.d.ts.map +1 -1
- package/dist/server/services/files/WebSiteContentService.js +21 -0
- package/dist/server/services/files/WebSiteContentService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/server/services/files/SnapshotService.ts +20 -0
- package/src/server/services/files/WebSiteContentService.ts +24 -0
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import { globalEnv } from "../../../common/globalEnv.js";
|
|
|
11
11
|
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
12
12
|
import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
|
|
13
13
|
import MessagingService from "../message-events/MessagingService.js";
|
|
14
|
+
import WebSiteContentService from "./WebSiteContentService.js";
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
let cdn = globalEnv.cdn || "";
|
|
@@ -27,6 +28,9 @@ export default class SnapshotService
|
|
|
27
28
|
@Inject
|
|
28
29
|
db: SocialMailContext;
|
|
29
30
|
|
|
31
|
+
@Inject
|
|
32
|
+
wcs: WebSiteContentService;
|
|
33
|
+
|
|
30
34
|
@Inject
|
|
31
35
|
storage: BaseStorage;
|
|
32
36
|
|
|
@@ -121,6 +125,22 @@ export default class SnapshotService
|
|
|
121
125
|
|
|
122
126
|
this.ms.snapshotRefresh.notify({ folderID });
|
|
123
127
|
|
|
128
|
+
const ws = await this.wcs.getCurrentSnapshotFolder(folderID);
|
|
129
|
+
|
|
130
|
+
// in case of design, we need to fix template.html to reference
|
|
131
|
+
// cdn image to reduce load time
|
|
132
|
+
if (ws.isDesign) {
|
|
133
|
+
const templateFile = await this.db.appFiles.where(ws, (p) => (x) => x.parentID === p.snapshotFolderID
|
|
134
|
+
&& x.name === "template.html")
|
|
135
|
+
.first();
|
|
136
|
+
if (templateFile) {
|
|
137
|
+
const templateFileContent = await this.wcs.getSnapshotFile(ws, ["template.html"]);
|
|
138
|
+
// we need to save the file content..
|
|
139
|
+
await this.storage.updateFile(templateFile, templateFileContent);
|
|
140
|
+
await db.appFiles.statements.update({ fileContentID: templateFile.fileContentID}, { appFileID: templateFile.appFileID });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
124
144
|
return snapshotRoot;
|
|
125
145
|
|
|
126
146
|
}
|
|
@@ -121,6 +121,30 @@ export default class WebSiteContentService
|
|
|
121
121
|
} as ISiteFolder;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
async getCurrentSnapshot(folderID) {
|
|
125
|
+
|
|
126
|
+
const site = await this.db.websiteFolders.where({ folderID }, (p) => (x) =>
|
|
127
|
+
x.folderID === p.folderID)
|
|
128
|
+
.first();
|
|
129
|
+
if (!site) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const { host } = await this.db.websiteFolderHosts.where({ folderID }, (p) => (x) => x.folderID === p.folderID )
|
|
133
|
+
.first();
|
|
134
|
+
return {
|
|
135
|
+
snapshotFolderID: site.currentVersionID,
|
|
136
|
+
folderID: site.folderID,
|
|
137
|
+
isDesign: site.isDesign,
|
|
138
|
+
eSiteID: this.ecs.general.encrypt(site.folderID.toString()),
|
|
139
|
+
remoteUrl: site.remoteUrl,
|
|
140
|
+
isTemplate: site.isTemplate,
|
|
141
|
+
hasEmailTemplates: site.hasEmailTemplates,
|
|
142
|
+
draftMode: false,
|
|
143
|
+
cacheKey: site.currentVersionID.toString(),
|
|
144
|
+
host
|
|
145
|
+
} as ISiteFolder;
|
|
146
|
+
}
|
|
147
|
+
|
|
124
148
|
@cacheFor()
|
|
125
149
|
async getWebSiteFolder(folderID) {
|
|
126
150
|
return this.replicaReader.query((db) => db.websiteFolders.where({ folderID }, (p) => (x) => x.folderID === p.folderID)
|