@things-factory/announcement 10.1.260 → 10.1.262

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": "@things-factory/announcement",
3
- "version": "10.1.260",
3
+ "version": "10.1.262",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -36,18 +36,18 @@
36
36
  "@operato/shell": "^10.29.69",
37
37
  "@operato/styles": "^10.29.1",
38
38
  "@operato/utils": "^10.0.0",
39
- "@things-factory/ai-assistant": "^10.1.260",
40
- "@things-factory/attachment-base": "^10.1.260",
41
- "@things-factory/auth-base": "^10.1.260",
39
+ "@things-factory/ai-assistant": "^10.1.262",
40
+ "@things-factory/attachment-base": "^10.1.262",
41
+ "@things-factory/auth-base": "^10.1.262",
42
42
  "@things-factory/env": "^10.1.149",
43
- "@things-factory/i18n-base": "^10.1.260",
44
- "@things-factory/notification": "^10.1.260",
45
- "@things-factory/organization": "^10.1.260",
46
- "@things-factory/shell": "^10.1.260",
43
+ "@things-factory/i18n-base": "^10.1.262",
44
+ "@things-factory/notification": "^10.1.262",
45
+ "@things-factory/organization": "^10.1.262",
46
+ "@things-factory/shell": "^10.1.262",
47
47
  "graphql-scalars": "^1.22.0",
48
48
  "graphql-tag": "^2.12.6",
49
49
  "graphql-upload": "^15.0.2",
50
50
  "lit": "^3.1.2"
51
51
  },
52
- "gitHead": "72de583ba0394dcf8195ef723b0ee4217507e0e5"
52
+ "gitHead": "2d5babff1e0f83bb0dfdf2ec91e4e7c00f9ac5bd"
53
53
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { EntityManager, In, IsNull, LessThanOrEqual } from 'typeorm'
6
6
 
7
- import { checkPermission, User, UserStatus } from '@things-factory/auth-base'
7
+ import { requestHolds, User, UserStatus } from '@things-factory/auth-base'
8
8
  import { logger } from '@things-factory/env'
9
9
  import { translatorFor } from '@things-factory/i18n-base/translator'
10
10
  import { keepNoticeDelivery, noticeDeliveryOf, noticeLinkOf, sendNotice, sendNoticeWhenCommitted, type Notice } from '@things-factory/notification'
@@ -19,12 +19,7 @@ export const ANNOUNCEMENT_REF_TYPE = 'Announcement'
19
19
 
20
20
  /** Whether the request writes announcements - the one privilege of the module (`announcement.writing`). */
21
21
  export async function isWriter(context: any): Promise<boolean> {
22
- const state = context?.state ?? {}
23
- const { domain, user, unsafeIP, prohibitedPrivileges } = state
24
- if (!domain || !user) return false
25
- /* Asked once per request - a list asks it for each row. */
26
- state.__announcementWriter ??= checkPermission({ category: 'announcement', privilege: 'mutation', owner: true } as any, user, domain, unsafeIP, prohibitedPrivileges).then(Boolean)
27
- return await state.__announcementWriter
22
+ return await requestHolds(context, 'announcement', 'mutation')
28
23
  }
29
24
 
30
25
  /** The request's person as an audience sees them - asked once per request. */
@@ -107,7 +107,7 @@ beforeEach(async () => {
107
107
  })
108
108
 
109
109
  const ids = (...names: string[]) => names.map(name => people[name].id).sort()
110
- const contextOf = (who: string, writer = false) => ({ state: { domain, user: people[who], __announcementWriter: Promise.resolve(writer) } })
110
+ const contextOf = (who: string, writer = false) => ({ state: { domain, user: people[who], __privilegesHeld: new Map([['announcement:mutation', Promise.resolve(writer)]]) } })
111
111
 
112
112
  async function draft(audiences: { scope: string; targetId: string }[], extra: any = {}) {
113
113
  const one = await dataSource.getRepository(Announcement).save({ domain, title: '연말 휴무', body: '**12월 31일** 휴무', status: 'DRAFT', creator: people.writer, ...extra })