MCPcopy Create free account
hub / github.com/hashintel/hash / processQueueMessage

Function processQueueMessage

apps/hash-api/src/integrations/sync-back-watcher.ts:56–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54 const queue = new RedisQueueExclusiveConsumer(redis);
55
56 const processQueueMessage = () => {
57 queue
58 .pop(queueName, null, async (_message: string) => {
59 /**
60 * @todo H-124: implement a new 'entity change' publisher service so that this works.
61 */
62 const entityEdition = null;
63
64 const linearBotAccountId = await getMachineIdByIdentifier(
65 { graphApi },
66 { actorId: systemAccountId },
67 { identifier: "linear" },
68 ).then((maybeMachineId) => {
69 if (!maybeMachineId) {
70 throw new Error("Failed to get linear bot");
71 }
72 return maybeMachineId;
73 });
74
75 const {
76 entities: [entity],
77 } = await queryEntities(
78 { graphApi },
79 { actorId: linearBotAccountId },
80 {
81 filter: {
82 equal: [
83 { path: ["editionId"] },
84 /* @ts-expect-error: @todo H-124: implement a new 'entity change' publisher service so that this works. */
85 { parameter: entityEdition.entityEditionId },
86 ],
87 },
88 temporalAxes: fullDecisionTimeAxis,
89 includeDrafts: false,
90 includePermissions: false,
91 },
92 );
93
94 if (!entity) {
95 /**
96 * The linear bot may not have access to the entity, which means
97 * it it's probably not an entity that should be processed.
98 *
99 * @todo we probably want to avoid fetching the entity in the sync
100 * back watcher entirely, as we don't want to have a single actor
101 * that can read all entities in the graph. One way of avoiding this
102 * would be passing the `entityTypeId` of the modified entity so that
103 * the correct integration processor can be called based on the entity's
104 * type.
105 *
106 * @see https://linear.app/hash/issue/H-756
107 */
108 return;
109 }
110
111 sendEntityToRelevantProcessor({
112 entity,
113 graphApi,

Callers 1

Calls 5

getMachineIdByIdentifierFunction · 0.90
queryEntitiesFunction · 0.90
thenMethod · 0.80
popMethod · 0.65

Tested by

no test coverage detected