Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add typeName to webhook return (#106)

* feat: add typeName to body.item return

* chore: type fix

* test: add typeName to test return

* feat: add name to more instances of webhook returns

* chore: update types to make name required

authored by

Caleb McQuaid and committed by
GitHub
a6baadb8 b43dd5c1

+14 -6
+1 -1
server/graphql/datasources/ActionApi.ts
··· 217 217 correlationId, 218 218 targetItem: { 219 219 itemId, 220 - itemType: { id: itemType.id, kind: itemType.kind }, 220 + itemType: { id: itemType.id, kind: itemType.kind, name: itemType.name }, 221 221 }, 222 222 actorId, 223 223 actorEmail,
+1 -1
server/rule_engine/ActionPublisher.test.ts
··· 107 107 correlationId: "post-content:abc123" as CorrelationId<"post-content">, 108 108 targetItem: { 109 109 itemId: "item-123", 110 - itemType: { id: "type-123", kind: "CONTENT" as const }, 110 + itemType: { id: "type-123", kind: "CONTENT" as const, name: "Social Post" }, 111 111 }, 112 112 }; 113 113
+2 -1
server/rule_engine/ActionPublisher.ts
··· 79 79 */ 80 80 export type ActionTargetItem = 81 81 | ItemSubmission 82 - | { itemId: string; itemType: Pick<ItemType, 'id' | 'kind'> }; 82 + | { itemId: string; itemType: Pick<ItemType, 'id' | 'kind' | 'name'> }; 83 83 84 84 export function isFullSubmission( 85 85 input: ActionTargetItem, ··· 310 310 item: { 311 311 id: targetItem.itemId, 312 312 typeId: targetItem.itemType.id, 313 + typeName: targetItem.itemType.name, 313 314 }, 314 315 policies, 315 316 rules,
+1 -1
server/rule_engine/RuleEvaluator.ts
··· 33 33 policyIds?: string[]; 34 34 sourceType?: RuleExecutionSourceType | ActionExecutionSourceType; 35 35 }) 36 - | ReadonlyDeep<{ itemId: string; itemType: Pick<ItemType, 'id' | 'kind'> }>; 36 + | ReadonlyDeep<{ itemId: string; itemType: Pick<ItemType, 'id' | 'kind' | 'name'> }>; 37 37 38 38 export function isFullSubmission(input: RuleInput): input is ItemSubmission { 39 39 return 'data' in input && 'submissionId' in input && Boolean(input.data);
+1 -1
server/workers_jobs/RetryFailedNcmecDecisionsJob.ts
··· 216 216 correlationId, 217 217 targetItem: { 218 218 itemId, 219 - itemType: { id: itemType.id, kind: itemType.kind }, 219 + itemType: { id: itemType.id, kind: itemType.kind, name: itemType.name }, 220 220 }, 221 221 actorId: row.reviewer_id, 222 222 actorEmail: user?.email,
+8 -1
server/workers_jobs/RunUserRulesJob.ts
··· 12 12 'UserStatisticsService', 13 13 'closeSharedResourcesForShutdown', 14 14 'RuleModel', 15 + 'getItemTypeEventuallyConsistent', 15 16 ], 16 - (RuleEngine, userStatisticsService, sharedResourceShutdown, Rule) => ({ 17 + (RuleEngine, userStatisticsService, sharedResourceShutdown, Rule, getItemTypeEventuallyConsistent) => ({ 17 18 type: 'Job' as const, 18 19 async run() { 19 20 // TODO: we may have to do only some orgs per job run at some point. ··· 39 40 return; 40 41 } 41 42 43 + const itemType = await getItemTypeEventuallyConsistent({ 44 + orgId, 45 + typeSelector: { id: userTypeId }, 46 + }); 47 + 42 48 await RuleEngine.runRuleSet( 43 49 rulesForUser, 44 50 RuleEngine.makeRuleExecutionContext({ ··· 48 54 itemType: { 49 55 id: userTypeId, 50 56 kind: 'USER', 57 + name: itemType?.name ?? "unknown", 51 58 }, 52 59 }, 53 60 }),