Commit Graph

41 Commits

Author SHA1 Message Date
Conrad Hoffmann fce16cc33e Use uppercase string for icon in patchset update
In GraphQL, the icon has to be uppercase [1]. However, the builds worker
uses the `JobContext.Job.Status` field in the payload [2], where the
value is lowercase [3]. Hence, upper-case the value before sending it to
the GraphQL API.

[1] https://git.sr.ht/~sircmpwn/lists.sr.ht/tree/master/item/api/graph/schema.graphqls#L468-474
[2] https://git.sr.ht/~sircmpwn/builds.sr.ht/tree/master/item/worker/triggers.go#L251
[3] https://git.sr.ht/~sircmpwn/builds.sr.ht/tree/master/item/worker/triggers.go#L109
2022-12-02 12:27:38 +01:00
Conrad Hoffmann ec7a552ffc webhooks: add error handling for patch submission
Currently, any 400 error that occurs will be swallowed by
`SrhtService.post()` [1] - the caller must use a validation object to
become aware of an error.

This commit adds such error handling by means of a validation object to
the build submission webhook.

[1]: https://git.sr.ht/~sircmpwn/hub.sr.ht/tree/f37b9e6e/item/hubsrht/services.py#L56-60
2022-11-25 10:24:17 +01:00
Drew DeVault f37b9e6e18 Update patchset build submission to use GQL API 2022-11-09 11:53:43 +01:00
Simon Ser 820b86cf9a Handle Closes commit trailers
References: c4bfcd1ff7
2022-07-26 13:43:56 +02:00
Conrad Hoffmann d637723564 Uppercase the Visibility enum keys
There is currently a mismatch, causing for example project creation via
the web interface to fail, because the validation code is using the enum
keys, which are lowercase, but everything else uses uppercase.

Simply use uppercase everywhere, like already the case in other
services.
2022-07-01 09:18:57 +02:00
Adnan Maolood 4e4f17770b hubsrht/blueprints/webhooks: Fix visibility 2022-06-29 18:05:26 +02:00
Drew DeVault 45a2f75b8b webhooks: prevent error on new/removed git refs 2022-03-21 10:28:10 +01:00
Robin Jarry 1b33a612d1 webhooks: avoid duplicate todo comments
When pushing a tag, the webhooks are invoked twice: once for the the
commit and once for the tag. Avoid inserting the same comment multiple
times. This also fixes the multiple comments issue when a git repository
is associated with more than one project.

This requires the new graphql method to get specific tickets by their
scoped ID on a given tracker.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-21 11:51:37 +01:00
Galen Abell 34c5650cd8 webhooks: Don't fail if there is no todo.sr.ht 2021-12-13 10:23:07 +01:00
Robin Jarry b5ebc44032 webhooks/git: use markdown for tracker comments
The raw body of comments is included in email notifications. HTML makes
ugly plain text messages.

Use markdown for generated tracker comments which can be used in plain
text emails as-is.

Fixes: https://todo.sr.ht/~sircmpwn/hub.sr.ht/77
Fixes: be5d50d8d8 ("webhooks: update todo tickets with git commits")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-29 14:57:27 +01:00
Robin Jarry be5d50d8d8 webhooks: update todo tickets with git commits
Allow referencing tracker tickets in git commit messages via specific
trailer words:

  Fixes: <ticket url>
  Implements: <ticket url>
  References: <ticket url>

These must follow standard git trailer syntax. The trailers are
extracted from commit messages with the function added in previous
commit. The ticket url must point to a valid ticket.

A comment will be inserted in the ticket with a back reference to the
git commit and its original author. The comment will be made by the user
who pushed the commit. E.g.:

  ~arkanoid REPORTED -> FIXED                          9 seconds ago

  John Doe referenced this ticket in commit b4dc4c40.

Open tickets referenced by a Fixes trailer will be resolved with the
FIXED resolution.

Open tickets referenced by an Implements trailer will be resolved with
the IMPLEMENTED resolution.

Caveats:

* Only the 25 most recent commit messages will be considered when
  pushing long series. This should be a fairly sane limitation.

* If the user pushing commits does not have triage/comment permissions
  on the bug tracker, nothing will happen.

* Invalid/non-existent ticket urls are ignored.

* When a git repository is part of more than one project, the webhook
  will run once per project and update the same ticket(s) once per
  project as well.

* If an already resolved ticket is referenced by a Fixes or Implements
  trailer, only a comment will be added.

Link: https://git-scm.com/docs/git-interpret-trailers
Implements: https://todo.sr.ht/~sircmpwn/hub.sr.ht/55
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-29 10:52:32 +01:00
Drew DeVault af1c1b3797 Fixes per lists.sr.ht updates 2021-10-06 10:02:14 +02:00
Drew DeVault caae0b5aa6 webhooks: handle trackers on multiple projects 2021-08-30 14:44:48 +02:00
Drew DeVault 207a992905 webhooks: fix unbound variable
Missed this one in a previous commit.
2021-08-23 16:59:57 +02:00
Drew DeVault 6fb2029120 webhooks: handle git repos on multiple projects
It is possible for one git repository to be added to several hub
projects, but the webhook was not prepared for this case.
2021-08-23 11:24:03 +02:00
Drew DeVault 6b0a06ba73 webhooks: HTML escape user content
This sounds like an XSS vulnerability, but really the only thing you can
exploit prior to this is silly things like putting an <h1> into commit
messages. These details were already sanitized at a later part of the
code.
2021-05-17 09:48:02 -04:00
Drew DeVault dba925cf4d webhooks: fix oversight in payload verification 2021-02-20 09:58:27 -05:00
Drew DeVault 641cd03056 Ignore webhooks from someone else's build 2021-02-20 09:53:43 -05:00
Drew DeVault 581af620f0 Rig up build status to lists.sr.ht tool status 2020-07-13 16:14:59 -04:00
Drew DeVault a1c9c80b29 Submit patches to builds.sr.ht 2020-07-13 13:30:28 -04:00
Drew DeVault 47d6ec09a1 Implement mailing list removal 2020-07-08 12:19:54 -04:00
Drew DeVault f6861ae2f5 webhooks: correct lists.sr.ht sender URL 2020-05-04 11:55:14 -04:00
Drew DeVault 546f0e47be webhooks: return response from unimplemented path 2020-05-04 11:08:08 -04:00
Drew DeVault 86f3f3351b Better webhook validation 2020-04-30 11:02:33 -04:00
Drew DeVault e8d313356c webhooks: verify payload signature 2020-04-30 10:27:09 -04:00
Drew DeVault 7d1cb671f3 Better handling of private or unlisted resources 2020-04-29 13:25:49 -04:00
Drew DeVault caa317cf5e Update projects on git commit events 2020-04-29 12:23:31 -04:00
Drew DeVault 313209a06e webhooks: handle lack of new refs on git push 2020-04-29 10:34:03 -04:00
Drew DeVault 15a3556c64 Rig up mailing list webhooks 2020-04-23 13:52:03 -04:00
Drew DeVault 83d9141023 Implement ticket comment events 2020-04-23 12:08:29 -04:00
Drew DeVault 7c3bb9fc0f Add events for todo.sr.ht tickets 2020-04-23 11:33:08 -04:00
Drew DeVault 8cafac751f Implement commit events 2020-04-20 17:12:23 -04:00
Drew DeVault 3d11d5dfe4 Flesh out webhooks somewhat
This handles deletion of the remote resource
2020-04-08 14:33:16 -04:00
Drew DeVault e0326ac0e2 Refactor webhooks to be more discrete 2020-04-06 16:19:07 -04:00
Drew DeVault 89a2e3ac9f Rig up Mercurial support 2020-04-06 13:21:13 -04:00
Drew DeVault fc586256cb Implement tracker update webhook 2020-04-02 10:13:01 -04:00
Drew DeVault ae7768cc70 Implement bug tracker addition 2020-04-02 09:24:29 -04:00
Drew DeVault a005c28fdf Flesh out webhooks a bit more 2020-03-31 16:09:33 -04:00
Drew DeVault c47f6ff49a Rig up git repo creation, webhooks 2020-03-31 11:40:55 -04:00
Drew DeVault f0f753bfd3 Add basic mailing lists support 2020-03-25 11:18:18 -04:00
Drew DeVault a50a47f7e6 Initial commit 2020-03-24 10:26:15 -04:00