@meith/subscriptions 0.33.4 → 0.35.0

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": "@meith/subscriptions",
3
- "version": "0.33.4",
3
+ "version": "0.35.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@meith/core": "0.33.4",
23
- "@meith/i18n": "0.33.4"
22
+ "@meith/core": "0.35.0",
23
+ "@meith/i18n": "0.35.0"
24
24
  }
25
25
  }
package/src/index.ts CHANGED
@@ -32,8 +32,8 @@ export {
32
32
  export type {
33
33
  PendingForUser,
34
34
  PendingPost,
35
+ SubscriberAudienceSource,
35
36
  SubscriptionNotifierPort,
36
37
  SubscriptionRepository,
37
38
  SubscriptionRow,
38
- VisibleForumSource,
39
39
  } from './types'
package/src/notifier.ts CHANGED
@@ -2,9 +2,9 @@ import { CADENCE_INTERVAL_MS, type DigestCadence, type SubscriptionMode } from '
2
2
  import { mintUnsubscribeToken } from './tokens'
3
3
  import type {
4
4
  PendingPost,
5
+ SubscriberAudienceSource,
5
6
  SubscriptionNotifierPort,
6
7
  SubscriptionRepository,
7
- VisibleForumSource,
8
8
  } from './types'
9
9
 
10
10
  export const MAX_USERS_PER_RUN = 50
@@ -53,7 +53,7 @@ export interface RunOutcome {
53
53
  export class SubscriptionNotifier {
54
54
  private readonly subscriptions: SubscriptionRepository
55
55
  private readonly notifications: SubscriptionNotifierPort
56
- private readonly forums: VisibleForumSource
56
+ private readonly forums: SubscriberAudienceSource
57
57
  private readonly now: () => Date
58
58
 
59
59
  private readonly secret: string | null
@@ -61,7 +61,7 @@ export class SubscriptionNotifier {
61
61
  constructor(deps: {
62
62
  subscriptions: SubscriptionRepository
63
63
  notifications: SubscriptionNotifierPort
64
- forums: VisibleForumSource
64
+ forums: SubscriberAudienceSource
65
65
  unsubscribeSecret?: string | null
66
66
  now?: () => Date
67
67
  }) {
@@ -154,11 +154,11 @@ export class SubscriptionNotifier {
154
154
  considered += 1
155
155
 
156
156
  try {
157
- const visibleForumIds = await this.forums.visibleForumIdsFor(userId)
157
+ const audience = await this.forums.audienceFor(userId)
158
158
  const pending = await this.subscriptions.pendingFor({
159
159
  userId,
160
160
  mode,
161
- visibleForumIds,
161
+ audience,
162
162
  limit: MAX_POSTS_PER_USER,
163
163
  })
164
164
 
package/src/service.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ThreadAudience } from '@meith/core'
1
2
  import { ValidationError } from '@meith/core'
2
3
  import { msg } from '@meith/i18n'
3
4
 
@@ -55,12 +56,9 @@ export class SubscriptionService {
55
56
  return this.repository.modeFor(userId, target, targetId)
56
57
  }
57
58
 
58
- async list(
59
- userId: number,
60
- visibleForumIds: readonly number[],
61
- ): Promise<readonly SubscriptionRow[]> {
59
+ async list(userId: number, audience: ThreadAudience): Promise<readonly SubscriptionRow[]> {
62
60
  return this.repository.listFor(userId, {
63
- visibleForumIds,
61
+ audience,
64
62
  limit: SUBSCRIPTIONS_PAGE_SIZE,
65
63
  })
66
64
  }
package/src/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { ThreadAudience } from '@meith/core'
2
+
1
3
  import type { DigestCadence, SubscriptionMode, SubscriptionTarget } from './modes'
2
4
 
3
5
  export interface SubscriptionRow {
@@ -53,7 +55,7 @@ export interface SubscriptionRepository {
53
55
 
54
56
  listFor(
55
57
  userId: number,
56
- options: { readonly visibleForumIds: readonly number[]; readonly limit: number },
58
+ options: { readonly audience: ThreadAudience; readonly limit: number },
57
59
  ): Promise<readonly SubscriptionRow[]>
58
60
 
59
61
  usersWithPending(input: {
@@ -65,7 +67,7 @@ export interface SubscriptionRepository {
65
67
  pendingFor(input: {
66
68
  readonly userId: number
67
69
  readonly mode: SubscriptionMode
68
- readonly visibleForumIds: readonly number[]
70
+ readonly audience: ThreadAudience
69
71
  readonly limit: number
70
72
  }): Promise<PendingForUser>
71
73
 
@@ -91,6 +93,6 @@ export interface SubscriptionNotifierPort {
91
93
  }): Promise<void>
92
94
  }
93
95
 
94
- export interface VisibleForumSource {
95
- visibleForumIdsFor(userId: number): Promise<readonly number[]>
96
+ export interface SubscriberAudienceSource {
97
+ audienceFor(userId: number): Promise<ThreadAudience>
96
98
  }