@social-mail/social-mail-web-server 1.8.371 → 1.8.373

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.8.371",
3
+ "version": "1.8.373",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/WebServer.ts CHANGED
@@ -228,6 +228,10 @@ export default class WebServer {
228
228
  return server;
229
229
  } catch (error) {
230
230
  console.error(error);
231
+ // if create fails...
232
+ // we need to kill the current process
233
+ // we will throw this error again
234
+ throw error;
231
235
  }
232
236
  }
233
237
 
@@ -44,7 +44,10 @@ export const globalEnv = {
44
44
  ips: (process.env.SOCIAL_MAIL_IPS ?? "").split(",").map((x) => x.trim()).filter((x) => x),
45
45
  senderEmailForNotification: process.env.SOCIAL_MAIL_SENDER_EMAIL_FOR_NOTIFICATION,
46
46
  cdn,
47
- cdnOrHost: cdn ?? host,
47
+ hosts:{
48
+ cdnOrHost: cdn ?? host,
49
+ emailContentHost: process.env.SOCIAL_MAIL_HOSTS_EMAIL_CONTENT || ""
50
+ },
48
51
  path: process.env.SOCIAL_MAIL_PATH || "/",
49
52
  links: {
50
53
  login: process.env.SOCIAL_MAIL_LINKS_LOGIN || process.env.SOCIAL_MAIL_EXTERNAL_LOGIN,
@@ -28,7 +28,7 @@ export default class ChannelUrlService {
28
28
  eDomain
29
29
  }: IFileUrlOptions): string {
30
30
  const cid = this.ecs.general.encrypt(file.fileContentID.toString());
31
- return `https://${globalEnv.cdnOrHost}/social-mail/video-player/${eDomain}/webm-branded/${cid}/${file.name}.b1.webm`;
31
+ return `https://${globalEnv.hosts.cdnOrHost}/social-mail/video-player/${eDomain}/webm-branded/${cid}/${file.name}.b1.webm`;
32
32
  }
33
33
 
34
34
  toWebMUrl({
@@ -38,7 +38,7 @@ export default class ChannelUrlService {
38
38
  }: IFileUrlOptions): string {
39
39
  const cid = this.ecs.general.encrypt(file.fileContentID.toString());
40
40
  if (eDomain) {
41
- return `https://${globalEnv.cdnOrHost}/social-mail/c/e/${eDomain}/webm-branded/${cid}/${file.name}.b1.webm`;
41
+ return `https://${globalEnv.hosts.cdnOrHost}/social-mail/c/e/${eDomain}/webm-branded/${cid}/${file.name}.b1.webm`;
42
42
  }
43
43
  if (publicRead) {
44
44
  this.ss.injectPublicKey(file);
@@ -78,7 +78,7 @@ export default class ChannelUrlService {
78
78
  name = `${file.name}.i1-${ext}`;
79
79
  }
80
80
  if (eDomain) {
81
- return `https://${globalEnv.cdnOrHost}/social-mail/c/e/${eDomain}/${method}/${cid}/${name}`;
81
+ return `https://${globalEnv.hosts.cdnOrHost}/social-mail/c/e/${eDomain}/${method}/${cid}/${name}`;
82
82
  }
83
83
  if (publicRead) {
84
84
  this.ss.injectPublicKey(file);
@@ -98,7 +98,7 @@ export default class ChannelUrlService {
98
98
  const method = "view";
99
99
  const name = file.name;
100
100
  if(eDomain) {
101
- return `https://${globalEnv.cdnOrHost}/social-mail/c/e/${eDomain}/${method}/${cid}/${name}`;
101
+ return `https://${globalEnv.hosts.cdnOrHost}/social-mail/c/e/${eDomain}/${method}/${cid}/${name}`;
102
102
  }
103
103
  if (publicRead) {
104
104
  this.ss.injectPublicKey(file);
@@ -10,6 +10,7 @@ import EmailLogService from "../../services/email-logs/EmailLogService.js";
10
10
  import EncryptionService from "../../services/encryption/EncryptionService.js";
11
11
  import { LocalFile } from "@entity-access/server-pages/dist/core/LocalFile.js";
12
12
  import BlogContentTransformer from "../../services/dom/BlogContentTransformer.js";
13
+ import { globalEnv } from "../../../common/globalEnv.js";
13
14
 
14
15
  @RegisterScoped
15
16
  export default class CachedEmailService {
@@ -69,12 +70,16 @@ export default class CachedEmailService {
69
70
  }
70
71
  const htmlService = ServiceProvider.resolve(this, BlogContentTransformer);
71
72
  if (status !== "draft") {
73
+ const { emailContentHost } = globalEnv.hosts;
74
+ const prefix = emailContentHost
75
+ ? `/api/emails/d/${ei}/${emailID}/`
76
+ : `https://${emailContentHost}/api/emails/d/${ei}/${emailID}/`;
72
77
  html = await htmlService.sanitizeExternalResources({
73
78
  html,
74
79
  emailID,
75
80
  messageID: void 0,
76
81
  senderDomain,
77
- prefix: `/api/emails/d/${ei}/${emailID}/`,
82
+ prefix,
78
83
  blog
79
84
  });
80
85
  }
@@ -4,6 +4,7 @@ import { existsSync, mkdirSync, unlinkSync, statSync, utimesSync, writeFileSync
4
4
  import { createHash } from "node:crypto";
5
5
  import sleep from "../../common/sleep.js";
6
6
  import { globalEnv } from "../../common/globalEnv.js";
7
+ import TimeoutError from "../../common/errors/TimeoutError.js";
7
8
 
8
9
  const tmpdir = globalEnv.tmpDir;
9
10
 
@@ -56,7 +57,8 @@ export default class LockFile implements Disposable {
56
57
  }while(now < till);
57
58
 
58
59
  if (throwOnFail) {
59
- throw new Error(`Could not acquire lock ${lastError?.stack ?? lastError?.toString()}`);
60
+ lastError ??= new TimeoutError("lock timed out");
61
+ throw new Error(`Could not acquire lock ${lockFile}, Reason: ${lastError?.stack ?? lastError?.toString()}`);
60
62
  }
61
63
 
62
64
  return {
@@ -109,9 +109,9 @@ export default class MailDispatcherService {
109
109
 
110
110
  const downloadLink = /^video\//i.test(ea.contentType)
111
111
  ? (listID
112
- ? `https://${globalEnv.cdnOrHost}/social-mail/c/d/${domainName}/webm-branded/${postID}/${ea.appFileID}/2-${fileName}/${fileName}.3.webm`
113
- : `https://${globalEnv.cdnOrHost}/social-mail/c/d/${domainName}/webm/${postID}/${ea.appFileID}/2-${fileName}/${fileName}.3.webm`)
114
- : `https://${globalEnv.cdnOrHost}/social-mail/c/d/${domainName}/view/${postID}/${ea.appFileID}/2-${fileName}`;
112
+ ? `https://${globalEnv.hosts.cdnOrHost}/social-mail/c/d/${domainName}/webm-branded/${postID}/${ea.appFileID}/2-${fileName}/${fileName}.3.webm`
113
+ : `https://${globalEnv.hosts.cdnOrHost}/social-mail/c/d/${domainName}/webm/${postID}/${ea.appFileID}/2-${fileName}/${fileName}.3.webm`)
114
+ : `https://${globalEnv.hosts.cdnOrHost}/social-mail/c/d/${domainName}/view/${postID}/${ea.appFileID}/2-${fileName}`;
115
115
 
116
116
  return {
117
117
  content: downloadLink,