ework-web 0.10.114 → 0.10.115
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 +1 -1
- package/src/giteaApi.ts +5 -0
- package/src/webhooks.ts +6 -4
package/package.json
CHANGED
package/src/giteaApi.ts
CHANGED
|
@@ -349,6 +349,11 @@ export async function handleGiteaApi(
|
|
|
349
349
|
const body = (await readJson(req).catch(() => ({}))) as { model?: unknown };
|
|
350
350
|
const model = typeof body.model === "string" ? body.model.trim() : "";
|
|
351
351
|
await updateCommentModel(cid, model);
|
|
352
|
+
const tagged = await getComment(cid);
|
|
353
|
+
if (tagged && model) {
|
|
354
|
+
const taggedIssue = await getIssueById(tagged.issue_id);
|
|
355
|
+
if (taggedIssue) void emitCommentEvent(project.id, taggedIssue.id, cid, origin, "edited");
|
|
356
|
+
}
|
|
352
357
|
return { status: 200, body: { ok: true, model } };
|
|
353
358
|
} catch (e) {
|
|
354
359
|
return giteaError(500, e instanceof Error ? e.message : String(e));
|
package/src/webhooks.ts
CHANGED
|
@@ -329,7 +329,7 @@ interface IssueEventPayload {
|
|
|
329
329
|
|
|
330
330
|
interface CommentEventPayload {
|
|
331
331
|
event_id?: string;
|
|
332
|
-
action: "created";
|
|
332
|
+
action: "created" | "edited";
|
|
333
333
|
issue: PayloadIssue;
|
|
334
334
|
comment: PayloadComment;
|
|
335
335
|
repository: PayloadRepository;
|
|
@@ -487,9 +487,10 @@ function buildCommentPayload(
|
|
|
487
487
|
origin: string,
|
|
488
488
|
model?: string,
|
|
489
489
|
labels: PayloadLabel[] = [],
|
|
490
|
+
action: "created" | "edited" = "created",
|
|
490
491
|
): CommentEventPayload {
|
|
491
492
|
return {
|
|
492
|
-
action
|
|
493
|
+
action,
|
|
493
494
|
issue: buildIssue(issue, project, commentCount, origin, model, labels),
|
|
494
495
|
comment: buildComment(issue, comment, project, origin),
|
|
495
496
|
repository: buildRepository(project, origin, model, issue.runtime || undefined),
|
|
@@ -710,7 +711,8 @@ export async function emitCommentEvent(
|
|
|
710
711
|
projectId: number,
|
|
711
712
|
issueId: number,
|
|
712
713
|
commentId: number,
|
|
713
|
-
origin: string
|
|
714
|
+
origin: string,
|
|
715
|
+
action: "created" | "edited" = "created"
|
|
714
716
|
): Promise<void> {
|
|
715
717
|
try {
|
|
716
718
|
const project = await getProjectById(projectId);
|
|
@@ -726,7 +728,7 @@ export async function emitCommentEvent(
|
|
|
726
728
|
const globalDefault = (await loadConfig()).defaultModel;
|
|
727
729
|
const model = resolveModel(project.model, globalDefault, issue.model);
|
|
728
730
|
const labels = await toPayloadLabels(issueId);
|
|
729
|
-
const payload = buildCommentPayload(issue, comment, project, commentCount, origin, model, labels);
|
|
731
|
+
const payload = buildCommentPayload(issue, comment, project, commentCount, origin, model, labels, action);
|
|
730
732
|
(payload as CommentEventPayload).event_id = randomUUID();
|
|
731
733
|
if (authorUser) {
|
|
732
734
|
payload.sender = buildUserFromRow(authorUser, origin);
|