Commit Graph

719 Commits

Author SHA1 Message Date
Simon Ser c4bfcd1ff7 Add CLOSED ticket resolution
This is a neutral resolution picked by default when the user doesn't
need/want to select a more precise resolution.
2022-07-25 13:44:18 +02:00
Adnan Maolood 75add26e2f api/graph: Fix duplicates in User.trackers query
Fixes: https://todo.sr.ht/~sircmpwn/todo.sr.ht/273
2022-07-24 09:27:03 +02:00
Adnan Maolood 268dacdc07 api/graph/model: Fix Tracker.QueryWithCursor 2022-06-29 17:22:01 +02:00
Adnan Maolood c116c0db22 api/graph: Conform to WebhookSubscription 2022-06-29 17:22:00 +02:00
Dean Weaver e93dff9824 Fix user mentions for usernames with a dash 2022-06-29 17:12:38 +02:00
Thorben Günther 0bb9ef9657 api/webhooks: Fix deletion error message for tickets 2022-06-14 10:09:19 +02:00
Adnan Maolood 0da003766d Update core-go 2022-05-30 14:19:15 +02:00
Adnan Maolood cdf9a77c46 api/graph: Ensure access when creating webhooks
Ensure that the user has access to the ticket/tracker when creating
ticket/tracker webhooks.
2022-05-30 13:36:08 +02:00
Adnan Maolood af242ca93e api/webhooks: Fix ticket/tracker webhook queries
Previously, we would only deliver tracker/ticket webhooks where the user
ID matched the currently authenticated user, which meant that
tracker/ticket webhooks for other users would not be delivered. This
updates the tracker/ticket webhook filters to allow other users to
receive webhook events while also ensuring that they have access to the
tracker.
2022-05-30 13:35:56 +02:00
Adnan Maolood f299d2f9a9 api/graph: Fix webhook subscription name 2022-05-30 13:35:06 +02:00
Adnan Maolood 7d65b3653c api/graph: Implement ticket deletion 2022-05-16 13:15:29 +02:00
Adnan Maolood 5650249985 todosrht: Fix 405 error when clicking 'next' in ticket list
When using the ticket preview feature, the URL would previously change
to /~user/tracker/submit. Attempting to navigate to the next page of
tickets afterwards would cause a 405 error since
/~user/tracker/submit?page=N is an invalid link.

Fix by changing the ticket submit route to /~user/tracker, so that
adding ?page=N results in a valid link.
2022-05-16 13:13:02 +02:00
Conrad Hoffmann 833e2a5588 Add api-origin to example config
If the service is not behind a reverse proxy (e.g. during local
development/testing) then this is needed by meta.sr.ht for API discovery
for all services that have a seperate API component. Add this (commented
out) to the example config, to make it easier to discover (and
require less documentation).
2022-05-10 10:30:23 +02:00
Adnan Maolood b779d41133 todosrht: Use proper access for Resolve button 2022-05-09 16:13:36 +02:00
Adnan Maolood 1e32f8eb9b api/loaders: Fix tracker queries 2022-05-09 16:13:31 +02:00
Adnan Maolood 322b245f4b api/graph/events: Fix query 2022-05-06 15:00:46 +02:00
Drew DeVault b7a3c26d24 API: Update core-go 2022-05-05 10:56:54 +02:00
Adnan Maolood b3e13fc94d api/graph/events: Use submitter info instead of auth info
Use the name and email of the submitter of the ticket for sending event
emails instead of the name and email of the currently authenticated
user.
2022-05-05 10:54:43 +02:00
Adnan Maolood 2521148108 api/graph/events: Add more headers 2022-05-05 10:54:43 +02:00
Adnan Maolood 10d9d29edb todosrht-lmtp: Use GraphQL for comment submission
Use GraphQL to submit comments from incoming emails so that
GraphQL-native webhooks are delivered.

Also use comments to document internal GraphQL mutations instead of
docstrings.

References: https://todo.sr.ht/~sircmpwn/sr.ht/315
2022-05-03 08:23:58 +02:00
Adnan Maolood 75a118a77d api/graph: Bump updated timestamps where necessary 2022-05-03 08:23:51 +02:00
Adnan Maolood 357ced1876 api/webhooks: Fix legacy event:create ticket id 2022-05-03 08:23:38 +02:00
Adnan Maolood e84fbbdddb api/graph: Improve error handling
Make mutations return errors when the resource is not found. Also
improve the error message when renaming a label to an existing label
name.

References: https://todo.sr.ht/~sircmpwn/sr.ht/300
2022-05-03 08:23:37 +02:00
Adnan Maolood 4b8eba4944 api/webhooks: Fix legacy event:create 'comment' webhook 2022-04-29 11:48:55 +02:00
Adnan Maolood fc6eecd33f api/graph: Make mutations return non-null values
References: https://todo.sr.ht/~sircmpwn/sr.ht/300
2022-04-29 11:09:53 +02:00
Adnan Maolood 646b1e55db api/graph: Add User.tracker query
Replace the tracker, trackerByName and trackerByOwner queries with a new
User.tracker query which is more graph-like.

References: https://todo.sr.ht/~sircmpwn/sr.ht/309
2022-04-29 11:09:52 +02:00
Adnan Maolood 8dd35065ed api/graph: Make createLabel consistent with updateLabel
Rename createLabel parameter names to match those used in
UpdateLabelInput.
2022-04-29 11:09:50 +02:00
Adnan Maolood 9a205600aa api/graph: Implement GraphQL-native ticket webhooks
Implement GraphQL-native ticket webhooks for ticket CRUD operations.
2022-04-29 11:09:40 +02:00
Adnan Maolood f495ccdf32 api/graph: Implement GraphQL-native tracker webhooks
Implement GraphQL-native tracker webhooks for tracker, label, and ticket
CRUD operations.
2022-04-29 11:09:39 +02:00
Adnan Maolood 467dd4075f api/webhooks: Fix legacy ticket event:create webhooks
Look up ticket webhook subscriptions by the ticket ID instead of the
ticket scoped_id.
2022-04-28 12:49:59 +02:00
Adnan Maolood 4c2e2792fa api/graph: Set resolution = UNRESOLVED for open tickets
Set resolution = UNRESOLVED for ticket statuses other than RESOLVED in
UpdateTicketStatus.
2022-04-28 12:49:59 +02:00
Adnan Maolood 037e2bf9fe todosrht: Use GraphQL for ticket CRUD operations
Use GraphQL for the remaining ticket CRUD operations.
2022-04-28 12:49:36 +02:00
Adnan Maolood 071d6ca781 api/server: Register @private directive 2022-04-18 11:14:28 +02:00
Drew DeVault 23ed990f12 Updates per jinja2 breaking changes 2022-04-11 22:10:33 +02:00
Adnan Maolood 67c96a4a54 todosrht-lmtp: Commit transaction before calling exec_gql
Commit the current transaction before calling exec_gql to ensure that
the senderId passed to the GraphQL API is always valid.
2022-04-11 11:27:28 +02:00
Adnan Maolood a250ca81ff todosrht-lmtp: Use tracker owner for exec_gql
Use the tracker owner as the user for exec_gql since the sender user may
be None (e.g. in the case of an email not associated with a user).
2022-04-11 11:27:27 +02:00
Adnan Maolood dee9e75762 todosrht-lmtp: Use GraphQL for ticket submission
Use GraphQL for ticket submission so that GraphQL TICKET_CREATED webhook
events are delivered.
2022-04-08 13:12:51 +02:00
Adnan Maolood ebb55fc95a todosrht: Use GraphQL for tracker CRUD operations
Use the GraphQL API for tracker CRUD operations so that GraphQL-native
user webhooks will be delivered.
2022-04-08 13:12:36 +02:00
Adnan Maolood ae7916d7fd api/graph: Implement GraphQL-native user webhooks
Implement GraphQL-native user webhooks for tracker creation, updates,
and deletion.
2022-04-08 13:12:23 +02:00
Adnan Maolood 65f5f914b9 api/graph: Retrieve defaultACL in deleteTracker mutation 2022-04-08 12:30:20 +02:00
Conrad Hoffmann c28e447d07 API: prevent "zero" timestamp on ticket creation
In Go, an un-initialized `time.Time` has a value of "0" which the
GraphQL server will accept (as it is not `nil`) and PostgreSQL will
write it to the database. However, the API will afterwards fail to
return the creation date for this ticket, as the value is considered
null, but the ticket type defined to not allow null.

As a first step, prevent clients from creating tickets with the "0"
timestamp by adding a validation that checks the value.

References: https://todo.sr.ht/~sircmpwn/todo.sr.ht/259
2022-04-08 12:30:10 +02:00
Drew DeVault bb414aae31 API: Fix table name for event
The extra quoting here is unnecessary, it's done elsewhere.

Fixes: https://todo.sr.ht/~sircmpwn/todo.sr.ht/268
2022-03-30 10:11:09 +02:00
Adnan Maolood baad258c05 api/graph: Fix panic in SubmitTicket for external participants
Previously, calling the submitTicket mutation with an externalId would
panic due to the participant variable not being properly initialized.
2022-03-29 10:30:29 +02:00
Adnan Maolood d8837e4494 api/graph: Fix constraint name 2022-03-29 10:30:18 +02:00
Adnan Maolood 5d2deed72a api/graph/events: Fix panic for external participants in SendEmail
Previously, SQL queries in SendEmail would return NULL for participant
types other than 'user' or 'email'. This would panic for participant
types like 'external' since NULL cannot be scanned to a string, which
caused the submitTicket mutation to fail when called with an externalId.
Fix by returning and checking for an empty string instead.
2022-03-29 10:30:07 +02:00
Adnan Maolood 65f1cafa0a api/graph: Improve error handling
This takes advantages of the improvements to core-go/valid, which allow
us to remove various placeholder errors. This also fixes a few broken
error checks which call err.Error() even when the err is nil, causing a
panic on success.
2022-03-29 10:29:58 +02:00
Adnan Maolood 54c1ca8c31 api/graph/model/tracker: Add default_access field
Fixes: https://todo.sr.ht/~sircmpwn/todo.sr.ht/265
2022-03-29 10:29:37 +02:00
Drew DeVault c6cb99ed8b Remove models_gen.go 2022-03-24 14:44:03 +01:00
Drew DeVault a00fbfc7a0 api: overhaul build 2022-03-24 14:09:55 +01:00
Drew DeVault e03387006e Add indexes to speed up tracker deletions
Fixes https://todo.sr.ht/~sircmpwn/todo.sr.ht/266
2022-03-21 11:52:13 +01:00