Commit Graph

133 Commits

Author SHA1 Message Date
Conrad Hoffmann 9670ee1409 Do not show profiles of suspended accounts
This should likely be extended to other services as well, but the hub is
certainly a good point to start.
2024-02-09 11:25:04 +01:00
Drew DeVault c85b4182a6 Revert "users.summary_GET: fetch user details via GQL"
This reverts commit 52c5caecb4.

Breaks access for non-logged-in users.
2024-01-18 11:09:03 +01:00
Drew DeVault 52c5caecb4 users.summary_GET: fetch user details via GQL 2024-01-18 10:53:47 +01:00
Drew DeVault ba1e43917b Fix conn.execute with new SQLAlchemy version 2023-10-31 08:55:03 +01:00
Vlad-Stefan Harbuz fb56d7ba60 add project RSS feed
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
2023-02-22 09:18:52 +01:00
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
Adnan Maolood 16dea8ac4d hubsrht: Match projects case-sensitively 2022-07-06 10:29:31 +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 7e78dc04d9 hubsrht/blueprints/sources: Fix visibility 2022-06-29 18:05:26 +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
Conrad Hoffmann d52edefe18 Avoid adding lists to project multiple times
If a list exists already it might also already be connected to the
project. If that is the case, simply skip processing this list.

Fixes: https://todo.sr.ht/~sircmpwn/hub.sr.ht/83
2022-03-14 12:55:29 +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
Drew DeVault b2e5433d30 projects.py: print readme exceptions 2022-02-14 17:53:23 +01:00
Adnan Maolood a77998c012 hubsrht: Remove usage of repository(id) GraphQL query
The repository(id) query will be removed from git.sr.ht, so use the
User.repository(name) query instead.
2022-02-14 15:42:51 +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 060b91237b Remove popular tags 2021-11-28 11:26:59 +01:00
Drew DeVault c34944b943 trackers: configure with visibility
Following the introduction of visibility parameters to todo.sr.ht.

Fixes ~sircmpwn/hub.sr.ht#75
2021-10-29 10:55:05 +02:00
Drew DeVault 48aadb5b1c Correct syntax error in previous change
I would have sworn that I had tested that.
2021-10-06 10:06:51 +02:00
Drew DeVault af1c1b3797 Fixes per lists.sr.ht updates 2021-10-06 10:02:14 +02:00
Sebastian LaVine 809792c0d0 Remove misplaced word 2021-09-21 09:20:43 +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 84710264d5 Fetch existing resources for sources, trackers
This is a generalization of the previous bug fix.
2021-08-12 08:21:29 +02:00
Sol Fisher Romanoff 1426569187 Make project names match [A-Za-z0-9._-]+
Project names in URLs are now case-insensitive --
This might break existing projects.

Also prohibits use of '.git' and '.hg' as project names.
2021-08-11 09:41:50 +02:00
Drew DeVault 9add0bfac7 mailing lists: fetch lists on validation error
This fixes a crash which would occur if you had a validation error in
your form submission.
2021-08-09 09:06:51 +02:00
Drew DeVault 7c9bff2e86 Prohibit projects named . or .. 2021-06-12 11:54:06 -04: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 610accc580 Add list of popular tags to project index 2021-03-03 14:48:58 -05:00
Drew DeVault 27b0dba424 blueprints.trackers: import abort from flask 2021-02-21 19:32:23 -05: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
Alexey Yerin c86e3280d7 Show last five repos when trying to clone project
Repositories are sorted by latest update time, like on "sources" tab.

Ticket: https://todo.sr.ht/~sircmpwn/hub.sr.ht/61
2021-01-29 10:35:00 -05:00
Drew DeVault b75ac04029 Tolerate # symbol in tag entry 2021-01-18 15:29:02 -05:00
Drew DeVault 5c97b72d51 Replace more git.sr.ht requests with GraphQL 2020-12-03 11:46:55 -05:00
Drew DeVault bd37e09523 Use GraphQL to fetch readmes from git.sr.ht 2020-12-03 08:33:47 -05:00
Drew DeVault 2220ddf633 Don't hide projects which didn't complete checklist
The UX here is pretty bad and at least a third of users are unaware that
they need to complete the checklist to publish their project.
2020-11-15 14:19:35 -05:00
Drew DeVault 8737b4881d Make project tags optional
Didn't notice this in the original patchset
2020-09-12 09:57:41 -04:00
наб dc078f279f Add project tags
Ref: ~sircmpwn/hub.sr.ht#19
2020-09-12 09:10:26 -04:00
наб df5ddcc3cb Test for & display invalid search errors on profile page, too
I was there indeed
2020-09-11 09:56:57 -04:00
Drew DeVault 134c1f27d6 Test for & display invalid search errors
Hi nab-was-here
2020-09-10 10:09:03 -04:00
наб ff01082c30 Move {git,hg}_new_GET into common handler; use correct origin for /~u/p/{git,hg}/new
Ref: ~sircmpwn/hg.sr.ht/39
2020-09-07 11:35:05 -04:00
Drew DeVault 29e04b2105 sources: import abort 2020-08-30 16:04:24 -04:00
наб adee08b766 Spec search_keys=sort for /projects 2020-08-24 10:04:54 -04:00