Commit Graph

783 Commits

Author SHA1 Message Date
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
Thorben Günther 1f552accae parseColor: Fix panic in hex.Decode
An input like '#AAAAAAAA' causes hex.Decode to panic. While this
solution does not allow color codes with length 3, those return an error
in hex.Decode either way.
2022-03-14 12:25:24 +01:00
Adnan Maolood 8539d6c21b api: go fmt 2022-03-14 12:13:40 +01:00
Adnan Maolood 02b9b60e94 api/graph: Remove usage of database.Apply 2022-03-14 12:13:05 +01:00
Drew DeVault 5e95e4ebb6 API: Filter ticket update on submitComment
That was a pretty bad oversight
2022-03-11 08:48:07 +01:00
Eyal Sawady 9222cb4823 .builds/alpine.yml: upgrade to 3.15 2022-02-28 11:14:11 +01:00
Drew DeVault 31ec3f7982 tracker.html: add noindex for unlisted trackers 2022-02-04 13:00:20 +01:00
Drew DeVault 1a843cbd91 .builds/alpine: drop -t from SSH 2022-02-01 09:34:00 +01:00
Drew DeVault 889c76571e API: Implement defaultACL 2022-02-01 09:28:46 +01:00
Drew DeVault 8af448ab7d API: Correct event type in unassignUser 2022-02-01 09:28:46 +01:00
Drew DeVault eafb72115f API: Validate external URL on submitTicket 2022-02-01 09:28:46 +01:00
Drew DeVault 99a9d92879 API: Refactor label color parsing into common func 2022-02-01 09:28:46 +01:00
Drew DeVault ebfabb2450 API: Add *ACL.SetBits functions
De-duplicates this code a bit.
2022-02-01 09:28:46 +01:00
Drew DeVault b9e95b1a21 API: Fix nit with variable declarations
I like to use the var keyword when declaring many variables at once, but
I can drop the types here for sure.
2022-02-01 09:28:46 +01:00
Drew DeVault a1ed38fc17 API: Use struct{} for user mention set 2022-02-01 09:28:46 +01:00
Drew DeVault 258514b8ef API: Use unique ticket reference as map key 2022-02-01 09:28:46 +01:00
Drew DeVault d19da4a6c8 API: Remove obsolete TODO, add needed TODOs 2022-02-01 09:28:45 +01:00
Drew DeVault 885e86fb16 Rig up ticket event legacy webhooks 2022-02-01 09:28:45 +01:00
Robin Jarry a40ca24ea3 API: Allow getting tickets from their scoped id
Add an api method to retrieve the ticket associated with a scoped ID for
a given tracker.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-01 09:28:45 +01:00
Drew DeVault 505495ae39 Legacy API: disallow new webhook creation
These are a mess and no one uses them, so let's keep it that way and
skip re-implementing all of this properly.
2022-02-01 09:28:45 +01:00
Simon Ser a1158c25ff api/graph: rename Subscription to ActivitySubscription
The GraphQL "Subscription" type is special and used for defining
subscription operations. Pick a different name so that GraphQL
parsers don't get confused.

References: https://todo.sr.ht/~sircmpwn/sr.ht/302
2022-02-01 09:28:45 +01:00
Simon Ser 28496b85cd api/graph/model: fix incorrect format directive
Fixes the following error found by `go test`:

    graph/model/participant.go:14:10: Sprintf format %s has arg e.Name of wrong type *string
2022-02-01 09:28:45 +01:00
Simon Ser ae5188e50d go generate 2022-02-01 09:28:45 +01:00
Simon Ser 75fcaf5dba go fmt 2022-02-01 09:28:45 +01:00
Simon Ser ef5f90d428 api/graph: add missing non-null types
Entries of these lists cannot be null.
2022-02-01 09:28:45 +01:00
Simon Ser c718de746e api: import github.com/99designs/gqlgen
Create a new generate.go file which imports github.com/99designs/gqlgen.
This fixes this kind of error because go mod now knows about the
dependency:

    /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/cmd/gen.go:9:2: missing go.sum entry for module providing package github.com/urfave/cli/v2 (imported by github.com/99designs/gqlgen/cmd); to add:
    	go get github.com/99designs/gqlgen/cmd@v0.13.0
    /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/imports/prune.go:15:2: missing go.sum entry for module providing package golang.org/x/tools/go/ast/astutil (imported by github.com/99designs/gqlgen/internal/imports); to add:
    	go get github.com/99designs/gqlgen/internal/imports@v0.13.0
    /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/code/packages.go:8:2: missing go.sum entry for module providing package golang.org/x/tools/go/packages (imported by github.com/99designs/gqlgen/internal/code); to add:
    	go get github.com/99designs/gqlgen/internal/code@v0.13.0
    /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/imports/prune.go:16:2: missing go.sum entry for module providing package golang.org/x/tools/imports (imported by github.com/99designs/gqlgen/internal/imports); to add:
    	go get github.com/99designs/gqlgen/internal/imports@v0.13.0
    graph/resolver.go:7: running "go": exit status 1
    missing go.sum entry for module providing package github.com/vektah/dataloaden; to add:
    	go mod download github.com/vektah/dataloaden
    loaders/middleware.go:3: running "./gen": exit status 1
2022-02-01 09:28:45 +01:00
Simon Ser 4090f16880 api/graph: use GraphQL descriptions for docs 2022-02-01 09:28:45 +01:00
Drew DeVault 1b359ed7f9 API: Implement ticket:create legacy webhook 2022-02-01 09:28:45 +01:00
Drew DeVault 3ee8d3ada4 API: Implement legacy label:delete webhook 2022-02-01 09:28:45 +01:00
Drew DeVault bc8aab193e API: Implement legacy label:create webhook 2022-02-01 09:28:45 +01:00
Drew DeVault 4f5e9d7c70 API: Correct typo in panic messages 2022-02-01 09:28:45 +01:00
Drew DeVault f591aeb463 API: Rig up tracker:delete legacy webhook 2022-02-01 09:28:45 +01:00
Drew DeVault 9258e45f3f API: Add Tracker { defaultACL } stub 2022-02-01 09:28:45 +01:00
Drew DeVault 4d4ebc49e3 API: Legacy tracker:create & :update webhooks 2022-02-01 09:28:45 +01:00
Drew DeVault e514555a78 API: Implement labelTicket, unlabelTicket 2022-02-01 09:28:45 +01:00
Drew DeVault 0bd750c0d4 API: Implement unassignUser 2022-02-01 09:28:45 +01:00
Drew DeVault 47007c1a4c API: Implement assignUser 2022-02-01 09:28:45 +01:00