gcf-board 0.8.1 → 0.8.2

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.
@@ -185,15 +185,16 @@ export function createApp(o) {
185
185
  };
186
186
  /**
187
187
  * A message to item `item`'s thread of the project chat (AD-49), when the project has one and
188
- * the board read knows the item: the thread's id, else null.
188
+ * the board read knows the item: the answer that says so (the thread, the input line's id),
189
+ * else null.
189
190
  */
190
191
  const toThread = async (p, item, line) => {
191
192
  const board = await boardOf(p).catch(() => null);
192
193
  if (!board?.domain.chat || !board.agent?.rules || !idsOf(board).has(item))
193
194
  return null;
194
195
  const t = openTalk(p, item).id;
195
- await sendTalk(p, t, line, board);
196
- return t;
196
+ const sent = await sendTalk(p, t, line, board);
197
+ return { ok: true, talk: t, ...(typeof sent.id === 'string' ? { id: sent.id } : {}) };
197
198
  };
198
199
  const routes = [
199
200
  ['GET', /^\/api\/events$/, async (_req, res) => subscribe(res)],
@@ -320,7 +321,7 @@ export function createApp(o) {
320
321
  // No harness, so no run: a message goes to the item's thread all the same.
321
322
  const t = line.type === 'say' ? await toThread(p, m[2], line) : null;
322
323
  if (t)
323
- return send(res, 202, { ok: true, talk: t });
324
+ return send(res, 202, t);
324
325
  throw e;
325
326
  }
326
327
  const chat = [harness, 'chat', m[2]];
@@ -348,7 +349,7 @@ export function createApp(o) {
348
349
  // An item the board read knows: a stale or mistyped id gets no thread.
349
350
  const t = r.code === 3 && line.type === 'say' ? await toThread(p, m[2], line) : null;
350
351
  if (t)
351
- return send(res, 202, { ok: true, talk: t });
352
+ return send(res, 202, t);
352
353
  const why = briefError(r.err || r.out).replace(/^[\w-]+ chat: /, '');
353
354
  if (/unknown command 'chat'/.test(why))
354
355
  throw new HttpError(400, 'the chat needs gcf-harness-aif-ext 0.11.0 or later');