@social-mail/social-mail-web-server 1.4.991 → 1.4.992
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/common/StringFormat.d.ts +4 -0
- package/dist/common/StringFormat.d.ts.map +1 -0
- package/dist/common/StringFormat.js +11 -0
- package/dist/common/StringFormat.js.map +1 -0
- package/dist/server/model/events/HostedZoneEvents.d.ts.map +1 -1
- package/dist/server/model/events/HostedZoneEvents.js +1 -75
- package/dist/server/model/events/HostedZoneEvents.js.map +1 -1
- package/dist/server/workflows/dns/SyncDnsZoneRecordsWorkflow.d.ts.map +1 -1
- package/dist/server/workflows/dns/SyncDnsZoneRecordsWorkflow.js +18 -12
- package/dist/server/workflows/dns/SyncDnsZoneRecordsWorkflow.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/StringFormat.ts +12 -0
- package/src/server/model/events/HostedZoneEvents.ts +1 -87
- package/src/server/workflows/dns/SyncDnsZoneRecordsWorkflow.ts +20 -12
package/package.json
CHANGED
|
@@ -40,94 +40,8 @@ export default class HostedZoneEvents extends AuthenticatedEvents<HostedZone> {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
async afterInsert(entity: HostedZone, entry: ChangeEntry<HostedZone>) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await entry.loadNavigationAsync((x) => x.domain);
|
|
46
|
-
|
|
47
|
-
const { zoneID, domain: { name: domain } } = entity;
|
|
48
|
-
|
|
49
|
-
const dateCreated = DateTime.now;
|
|
50
|
-
const dateUpdated = dateCreated;
|
|
51
|
-
|
|
52
|
-
// add some default records...
|
|
53
|
-
const db = ServiceProvider.resolve(this, SocialMailContext);
|
|
54
|
-
|
|
55
|
-
const ttl = 8600;
|
|
56
|
-
|
|
57
|
-
for (const soa of globalEnv.dns.soa) {
|
|
58
|
-
await db.hostedZoneRecords.statements.insert({
|
|
59
|
-
zoneID,
|
|
60
|
-
dateCreated,
|
|
61
|
-
dateUpdated,
|
|
62
|
-
ttl,
|
|
63
|
-
name: "@",
|
|
64
|
-
type: "SOA",
|
|
65
|
-
value: soa,
|
|
66
|
-
readonly: true,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
await db.hostedZoneRecords.statements.insert({
|
|
72
|
-
zoneID,
|
|
73
|
-
dateCreated,
|
|
74
|
-
dateUpdated,
|
|
75
|
-
ttl,
|
|
76
|
-
name: "_acme-challenge",
|
|
77
|
-
type: "CNAME",
|
|
78
|
-
value: `${domain}.${globalEnv.dns.letsEncryptPrefix}`,
|
|
79
|
-
readonly: true,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
await db.hostedZoneRecords.statements.insert({
|
|
83
|
-
zoneID,
|
|
84
|
-
dateCreated,
|
|
85
|
-
dateUpdated,
|
|
86
|
-
ttl,
|
|
87
|
-
name: "_dmarc",
|
|
88
|
-
type: "TXT",
|
|
89
|
-
value: `v=DMARC1; p=reject; rua=mailto:no-reply@${domain};`,
|
|
90
|
-
readonly: true,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
await db.hostedZoneRecords.statements.insert({
|
|
94
|
-
zoneID,
|
|
95
|
-
dateCreated,
|
|
96
|
-
dateUpdated,
|
|
97
|
-
ttl,
|
|
98
|
-
type: "A",
|
|
99
|
-
name: "@",
|
|
100
|
-
value: "$IP$",
|
|
101
|
-
fqdn: `${domain}`,
|
|
102
|
-
readonly: true
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
await db.hostedZoneRecords.statements.insert({
|
|
106
|
-
zoneID,
|
|
107
|
-
dateCreated,
|
|
108
|
-
dateUpdated,
|
|
109
|
-
ttl,
|
|
110
|
-
type: "CNAME",
|
|
111
|
-
name: "www",
|
|
112
|
-
value: "$HOST$",
|
|
113
|
-
fqdn: `www.${domain}`,
|
|
114
|
-
readonly: true
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
await db.hostedZoneRecords.statements.insert({
|
|
118
|
-
zoneID,
|
|
119
|
-
dateCreated,
|
|
120
|
-
dateUpdated,
|
|
121
|
-
ttl,
|
|
122
|
-
type: "CNAME",
|
|
123
|
-
name: "*",
|
|
124
|
-
value: "$HOST$",
|
|
125
|
-
fqdn: `*.${domain}`,
|
|
126
|
-
readonly: true
|
|
127
|
-
});
|
|
128
|
-
|
|
129
43
|
const wc = ServiceProvider.resolve(this, WorkflowContext);
|
|
130
|
-
await SyncDnsZoneRecordsWorkflow.enqueue(wc, zoneID);
|
|
44
|
+
await SyncDnsZoneRecordsWorkflow.enqueue(wc, entity.zoneID);
|
|
131
45
|
}
|
|
132
46
|
|
|
133
47
|
}
|
|
@@ -7,6 +7,10 @@ import EmailAddressService from "../../services/EmailAddressService.js";
|
|
|
7
7
|
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
8
8
|
import { globalEnv } from "../../../common/globalEnv.js";
|
|
9
9
|
import GlobalEvents from "../../../common/GlobalEvents.js";
|
|
10
|
+
import StringFormat from "../../../common/StringFormat.js";
|
|
11
|
+
|
|
12
|
+
const toUnixDateAndHour = (date: Date | DateTime, d = DateTime.from(date)) =>
|
|
13
|
+
`${StringFormat.fixed(d.year, 4)}${StringFormat.fixed(d.month)}${StringFormat.fixed(d.day)}${StringFormat.fixed(d.hour)}`;
|
|
10
14
|
|
|
11
15
|
export default class SyncDnsZoneRecordsWorkflow extends Workflow {
|
|
12
16
|
|
|
@@ -60,18 +64,22 @@ export default class SyncDnsZoneRecordsWorkflow extends Workflow {
|
|
|
60
64
|
const dateCreated = DateTime.now;
|
|
61
65
|
const dateUpdated = dateCreated;
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
await db.hostedZoneRecords.statements.insert({
|
|
68
|
+
zoneID,
|
|
69
|
+
dateCreated,
|
|
70
|
+
dateUpdated,
|
|
71
|
+
ttl,
|
|
72
|
+
name: "@",
|
|
73
|
+
type: "SOA",
|
|
74
|
+
value: globalEnv.dns.soa.join(" ") + `(
|
|
75
|
+
${toUnixDateAndHour(dateCreated)}
|
|
76
|
+
28000
|
|
77
|
+
7200
|
|
78
|
+
604800
|
|
79
|
+
600
|
|
80
|
+
)`,
|
|
81
|
+
readonly: true,
|
|
82
|
+
});
|
|
75
83
|
|
|
76
84
|
|
|
77
85
|
await db.hostedZoneRecords.statements.insert({
|