Commit Graph

780 Commits

Author SHA1 Message Date
Drew DeVault 55f3024d88 tickets.py: fix issue with obsolete join usage 2024-03-20 16:22:07 +01:00
Drew DeVault b8d28e8eb8 Upgrade to Alpine 3.19 2024-03-20 14:28:45 +01:00
Drew DeVault a89f3a3c8a Upgrade dependencies 2024-03-19 11:53:13 +01:00
Drew DeVault f30fced074 API: add some logging
Mostly adding this temporarily to suss out spammers
2024-02-18 17:43:03 +01:00
Drew DeVault 8b0535fb20 .builds: drop debian, arch 2024-02-09 10:19:25 +01:00
Simon Ser ec29d07a68 makefile: add loaders to gqlgen deps
Without the loaders, gqlgen fails with:

    validation failed: packages.Load: /home/simon/src/todo.sr.ht/api/loaders/middleware.go:34:26: undefined: EntitiesByParticipantIDLoader
2024-01-31 12:00:43 +01:00
Simon Ser 4201564503 makefile: use grouped target for loaders
That way make will only run it once for the whole group.
2024-01-31 11:53:20 +01:00
Simon Ser b54691e436 makefile: don't re-generate if unchanged
Use make targets to skip "go generate" invocations when unnecessary.
2024-01-31 11:43:59 +01:00
Ersei Saggi dfda88c305 Use dir="auto" 2024-01-31 10:14:49 +01:00
Conrad Hoffmann 9096cc0af5 api: fully apply builder pattern to event builder
It seems to have been designed this way initially, but many functions
did not adhere.
2024-01-31 10:11:20 +01:00
Conrad Hoffmann fb651a7997 todosrht-lmtp: try a bit harder to parse msg ID
Even though it is rarely used, the full format of the Message-ID header
is (grossly simplified): "Comment to be ignored <actual@message.id>",
similar to an address. Parsing this as address will still be a bit too
lax (it would accept quoted string literals on the left-id side), but
it's at least much better than the current approach.
2024-01-31 10:11:18 +01:00
наб 7348b4a29b Include References: <Message-ID of triggering e-mail>, if any, in the comment notification
This mirrors the ticket_new notification
2024-01-26 11:47:47 +01:00
наб 80956c5981 Include an In-Reply-To: <Message-ID of triggering e-mail>, if any, in the new_ticket notification. Again
In commit 8a3c9b63b9 ("Include an
 In-Reply-To: <Message-ID of triggering e-mail>, if any,
 in the new_ticket notification") on 2020-07-17,
I made it so the return mail for a ticket submission
is a reply to the submission.

commit dee9e75762 ("todosrht-lmtp:
 Use GraphQL for ticket submission") on 2022-04-05 deletes this.

Why? Unclear. The patch submission in
  https://lists.sr.ht/~sircmpwn/sr.ht-dev/%3C20220405161354.11100-1-me%40adnano.co%3E
says this is the case but doesn't try to justify or rectify it.

Why? Unclear. Add it back because this is basic functionality.
2024-01-26 11:01:32 +01:00
Simon Ser 11d5155e34 Upgrade chi to v5 2024-01-24 15:18:32 +01:00
Simon Ser c0be6d1c5e Upgrade core-go 2024-01-24 12:11:43 +01:00
Krystian Chachuła 04489eb217 Disable 'Assign myself' button if already assigned
Closes: https://todo.sr.ht/~sircmpwn/todo.sr.ht/275
2024-01-24 09:49:30 +01:00
Conrad Hoffmann b8a65ae2be api: drop unnecessary recover 2024-01-21 20:30:25 +01:00
Krystian Chachuła 031383d55f Fix error when assigning already assigned user
Assigning user that is already assigned causes unhandled GraphQLError.
This commit adds validation that the user is not assigned.

References: https://todo.sr.ht/~sircmpwn/todo.sr.ht/275
2023-12-04 12:10:36 +01:00
Conrad Hoffmann 8ad96d48ce api: export mention event ticket references
Currently the JSON export does not set the `from_ticket` field for
events of type TICKET_MENTIONED. This commit implements writing out the
data as described in the legacy API docs:

https://man.sr.ht/todo.sr.ht/api.md#event-resource

Note that currently these events are not imported anyways (never have
been).
2023-12-04 12:10:36 +01:00
Thorben Günther 7e6b9628a4 api/schema: Rename import to importUpload
import is a keyword in Go, so gqlgen currently renames this to
importArg. importUpload fits better.
2023-11-21 16:51:26 +01:00
Jackson Chen 3f51bbe5ff limit length of new comments
same constraint in editing a comment
2023-10-24 12:43:51 +02:00
Jackson Chen 4bddb933ad require comment except for close/reopen 2023-10-24 12:43:51 +02:00
Jackson Chen a297b4254d make empty descriptions on tracker edit work
it's possible to create a tracker with an empty description, but not
edit a tracker to have an empty description.

the rewrite lambda turns empty strings into None, resulting in
descriptions being never updated if it's empty.
2023-10-24 12:43:50 +02:00
Jackson Chen 4c4e19a958 add client side checks for required form fields
matches server side validation behavior
2023-10-24 12:43:49 +02:00
Josh Soref 17f8b5115d spelling: unreachable
Signed-off-by: Josh Soref <jsoref@gmail.com>
2023-10-24 12:35:43 +02:00
Josh Soref a4d5c017c4 spelling: trackers
Signed-off-by: Josh Soref <jsoref@gmail.com>
2023-10-24 12:35:43 +02:00
Josh Soref b7a0b20c32 spelling: discussion
Signed-off-by: Josh Soref <jsoref@gmail.com>
2023-10-24 12:35:42 +02:00
Josh Soref df64a8990d spelling: nonexistent
Signed-off-by: Josh Soref <jsoref@gmail.com>
2023-10-24 12:35:42 +02:00
Josh Soref f7ba455a31 spelling: assignee
Signed-off-by: Josh Soref <jsoref@gmail.com>
2023-10-24 12:35:41 +02:00
Simon Ser a9b19262ce api/graph: fix invalid @access directive in WebhookEvent enum
Fixes the following schema error:

    Directive access is not applicable on ENUM_VALUE.
2023-10-24 12:35:21 +02:00
Simon Ser eabf5f18d7 api/graph: check tracker owner before starting import
We were checking the owner when updating the import_in_progress
column, but we were starting off the import even if the tracker
didn't exist or didn't belong to the user.
2023-10-24 12:32:56 +02:00
Simon Ser 046ae6de44 api/graph: implement import arg for createTracker mutation 2023-10-24 12:31:52 +02:00
Thorben Günther 7e1fbc789e api/trackers/export: Add missing nil checks
There are currently two cases that cause the export function to panic.

The first one happens, when the authenticated user does not have the
permissions to access the tracker. In that case the TrackersByID loader
returns nil, so we have to check for that.

The second one can happen for tickets that got mentioned by other
tickets. In that case event.Participant is nil. That is caused here in
tickets.py [1] where participant is only filled for user and
not for ticket mention events.

[1]: c2a87f590d/item/todosrht/tickets.py (L283)
2023-10-24 12:30:24 +02:00
Simon Ser 5dea43a8af api/loaders: fix null constraint violation on user.id
Fixes the following error:

    panic: pq: null value in column "id" of relation "user" violates not-null constraint

user.id is not a serial, it's an integer not null. Thus we always
need to specify it when inserting to the table.
2023-08-22 22:10:49 +02:00
Simon Ser eec641b3e4 schema: fix user.id type
This is no longer a serial after the canonical ID migration.
2023-08-22 22:10:42 +02:00
Simon Ser c2a87f590d api/graph: implement tracker export 2023-08-16 12:02:51 +02:00
Simon Ser 366713a3c2 api/trackers: fix fmt.Errorf arguments
Fixes the following:

    api/trackers/import.go:340:13: fmt.Errorf call needs 1 arg but has 2 args
2023-08-16 12:00:03 +02:00
Simon Ser d8cf6aed69 api/trackers: drop io.ReadAll
This improves readability and stops buffering the whole dump in
memory.
2023-08-16 11:59:58 +02:00
Thorben Günther d62bb5705f api/subscription: Fix QueryWithCursor 2023-08-16 11:59:41 +02:00
Thorben Günther 4dfed3ddfc api/label: Fix QueryWithCursor 2023-07-07 10:10:11 +02:00
Adnan Maolood 8d72d25080 Move go.mod to root
Also update go.mod to Go 1.16.
2023-04-11 15:01:21 +02:00
Conrad Hoffmann 14ae4b1035 Send all emails via meta.sr.ht sendEmail mutation
This removes all usage of `srht.send_email` from todo.sr.ht.
2023-04-11 15:01:20 +02:00
Conrad Hoffmann db76f013ca api: use only `sendEmail` mutation to send mails
Unify all sending of notification emails in the newly added meta.sr.ht
`sendEmail` mutation, which works for both registered users and email
paritcipants.
2023-04-11 15:01:19 +02:00
Thorben Günther d73cebbb6a api: Add labelByName resolver
The authorization check is already done by the fetchTrackersByOwnerName
loader.
2023-04-11 15:01:15 +02:00
Drew DeVault 8d94386c37 Upgrade to Alpine 3.17 2023-03-22 11:23:16 +01:00
Adnan Maolood 573e3b244b api/graph: Fix usage of valid.Error
valid.Error should only be used for form field errors which might be
shown to the user on the frontend. Since there is no userId field, the
error will not be surfaced, so use errors.New instead.
2023-03-13 15:03:03 +01:00
Conrad Hoffmann 210f551564 api: send event notifications via meta.sr.ht GQL
This commit implements the sending of event notification emails via the
meta.sr.ht GraphQL API, which will cause the emails to be properly
signed and potentially encrypted (according to the recipients privacy
settings).

Almost the entire SendEmail function had to be modified (though much of
it only moved). While doing so, a few minor issues were discovered and
also fixed:

* The check `if len(name) == 0 || len(address) == 0` was used to filter
  out "external" participants, but it also filtered out "email"
  participants that happened to not use a name in their From-header;
  fixed by checking the participant type as stored in the DB instead
* In the query for the event participants, the name of "email"
  participants was `Scan()`ned into a `string`, but it can be `NULL`;
  fixed by coalescing with empty string
* Removed the last usage of Squirrel in this file
2023-02-22 09:49:50 +01:00
Adnan Maolood a4ef456246 api/trackers: Always clear import flag on import error 2023-02-20 10:39:29 +01:00
Conrad Hoffmann ed005d6b4f Send out notifications to users via meta.sr.ht GQL
This moves handling of (potentially) encrypted emails into the
meta.sr.ht API. Emails to external addresses are still sent
(unencrypted) via the core.sr.ht Pyhon module.
2023-01-26 10:04:57 +01:00
Adnan Maolood 5c4ba72503 schema.sql: Fix syntax error 2023-01-26 09:55:45 +01:00