@social-mail/social-mail-web-server 1.4.976 → 1.4.978

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.4.976",
3
+ "version": "1.4.978",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,10 +22,21 @@ export default class HostedZone {
22
22
  })
23
23
  zoneID: number;
24
24
 
25
+ @Column({ dataType: "Char", nullable: true })
26
+ @ReadOnlyJsonProperty
27
+ unsigned: string;
28
+
29
+ @Column({ dataType: "Char", nullable: true })
30
+ @ReadOnlyJsonProperty
31
+ digest: string;
32
+
25
33
  domain: Domain;
26
34
  records: HostedZoneRecord[];
27
35
  users: HostedZoneUser[];
28
36
 
37
+ @JsonProperty({})
38
+ zone: string;
39
+
29
40
  }
30
41
 
31
42
  @Table("HostedZoneUsers")
@@ -7,6 +7,8 @@ import SocialMailContext from "../SocialMailContext.js";
7
7
  import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
8
8
  import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
9
9
  import { globalEnv } from "../../../common/globalEnv.js";
10
+ import EmailAddressService from "../../services/EmailAddressService.js";
11
+ import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
10
12
 
11
13
  export default class HostedZoneEvents extends AuthenticatedEvents<HostedZone> {
12
14
 
@@ -20,6 +22,21 @@ export default class HostedZoneEvents extends AuthenticatedEvents<HostedZone> {
20
22
  return query.where(this.sessionUser, (p) => (x) => x.users.some((u) => u.userID === p.userID));
21
23
  }
22
24
 
25
+ async beforeInsert(entity: HostedZone, entry: ChangeEntry<HostedZone>) {
26
+ if (this.verify) {
27
+ this.sessionUser.ensureIsAdmin();
28
+ }
29
+
30
+ const eas = ServiceProvider.resolve(this, EmailAddressService);
31
+
32
+ if (!entity.zoneID) {
33
+ if (!entity.zone) {
34
+ throw new EntityAccessError(`Zone name cannot be empty`);
35
+ }
36
+ entity.zoneID = await eas.getOrCreateDomain(entity.zone);
37
+ }
38
+ }
39
+
23
40
  async afterInsert(entity: HostedZone, entry: ChangeEntry<HostedZone>) {
24
41
 
25
42