~bigbes/core-go

942e19c3 — Simon Ser 2 years ago
s3: add Enabled
864816cf — Simon Ser 2 years ago
client: rename Execute to Do

583d0b1bcb08 ("client/graphql: handle GraphQL errors") changed
Execute behavior by wrapping the result into a struct with "data"
and "errors" fields. This is a breaking change, but it's hard to
spot when upgrading core-go because it won't cause a compilation
error.

Rename Execute to Do to break the build and force callers to update
accordingly.
23808bb0 — Simon Ser 2 years ago
auth: add RequireMiddleware

Same as Middleware, but requires auth for all requests. Will be
useful to drop hacks from pages.sr.ht.
d99f0983 — Simon Ser 2 years ago
s3: add [objects]s3-insecure

Disables TLS. Useful for local development.
e81358e2 — Simon Ser 2 years ago
s3: add NewClient and URL

Centralizes the logic to create an S3 client and get the base URL.
1063e5b6 — Simon Ser 2 years ago
email: make PGP private key optional

Services other than meta.sr.ht don't really have a use for the
private PGP key.

Add a CanPGPSign method so that meta.sr.ht can emit a warning or
error when the PGP key is missing.
583d0b1b — Simon Ser 2 years ago
client/graphql: handle GraphQL errors

Instead of leaving it up to the caller to check for GraphQL errors,
centralize in core-go.
a88277c1 — Simon Ser 2 years ago
email: improve mail.ParseAddress error message
453dcaef — Simon Ser 2 years ago
server/directives: disambiguate AnonInternal error message

AUTH_INTERNAL won't work with AnonInternal.
53966da2 — Simon Ser 2 years ago
Drop gqlparser v1 dependency

Only use v2 throughout the repository.
2e7ac4ec — Conrad Hoffmann 2 years ago
Update and simplify build manifest

Alpine 3.14 uses Go 1.16, but go.mod says 1.17. Also, no external
repository should be required for core-go.
cd878493 — Conrad Hoffmann 2 years ago
webhooks: skip webhooks with expired credentials

The documentation states [1]:

> When the original authentication method becomes invalid (such as the
> expiration of or revocation of an OAuth 2.0 bearer token), the
> webhook is disabled.

However, this is currently not the case. Expired webhooks are indeed
filtered out in virtually all GraphQL queries (by means of core-go's
FilterWebhooks [2]), so users cannot see or delete them. They are _not_
filtered out upon scheduling, however. This commit fixes that.

The symptoms of this are that active webhooks may simply not be run - if
a user has both an expired and a valid, active webhook for some event,
the scheduling will retrieve both, fail on the expired one, and stop
processing, without any feedback to the user who scheduled the hooks.

This is a problem across all services, so core-go seems like the best
place to fix this.

[1]: https://man.sr.ht/graphql.md#webhook-authentication
[2]: https://git.sr.ht/~sircmpwn/core-go/tree/master/item/webhooks/config.go#L74,81
d2ad494f — Simon Ser 2 years ago
Migrate to chi v5

v1 is not maintained anymore.
3902e4bd — Simon Ser 2 years ago
database: don't panic on context.DeadlineExceeded

Checking context.Cancelled is not enough, I also see the same issue
with context.DeadlineExceeded:

    panic: Transaction error: driver: bad connection
    Closure error: context deadline exceeded

    goroutine 66664 [running]:
    git.sr.ht/~sircmpwn/core-go/database.WithTx({0x5578e1847a58, 0xc0002c44e0}, 0x50?, 0xc000285f38)
            e7b8e02696a1">git.sr.ht/~sircmpwn/core-go@v0.0.0-20231129165057-e7b8e02696a1/database/middleware.go:74 +0x2ce
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.fetchUsersByID.func1({0xc0002cf190, 0x1, 0x1})
            git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/middleware.go:34 +0x118
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).end(...)
            git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:222
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).startTimer(0xc00044a360, 0xc00042d380)
            git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:218 +0xe7
    created by git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).keyIndex
            git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:191 +0x119
86ad9b5a — Conrad Hoffmann 2 years ago
server/email: use go-message for address parsing

No need to additionally depend on net/mail
e7b8e026 — Simon Ser 2 years ago
database: print both errors in WithTx

Make it easier to debug panics by printing both errors instead of
sending one of them to /dev/null.
7f5f7071 — Simon Ser 2 years ago
database/middleware: fix error value used in panic

We were checking txErr, but panic'ing with err.

Fixes: a06a6247898c ("database: don't panic with ErrBadConn")
cfae7bae — Simon Ser 3 years ago
Upgrade dependencies
72c2f060 — Simon Ser 3 years ago
database: specify field name for graphql.CollectedField

Newer versions of the graphql package add new fields to this struct.
This results in errors:

    database/ql.go:40:4: too few values in struct literal of type graphql.CollectedField
    database/ql.go:71:4: too few values in struct literal of type graphql.CollectedField
bf4fe19c — наб 2 years ago
email: EnqueueStd: set Content-Type with charset=UTF-8 instead of just text/plain

Mails are now
	--11d2cbf164a9ae0dfbb310faf818762607dcfd20aa74e07c7be0eec1458d
	Mime-Version: 1.0
	Content-Transfer-Encoding: quoted-printable
	Content-Type: text/plain; charset=UTF-8

	=D1=82=D1=80=D1=83=D0=BF=D0=B08

	--=20
	View on the web: http://192.168.1.101:5003/~nab2/trupa/8
	--11d2cbf164a9ae0dfbb310faf818762607dcfd20aa74e07c7be0eec1458d
	Content-Type: application/pgp-signature

	-----BEGIN PGP MESSAGE-----

	wnUEARYIACcFAmUavj0JkKdioLsBS5scFiEE+ts/9LaoXcZuSmrHp2KguwFLmxwA
	AIm9AP9KB4cZyiby7jiiRMRESDeJXrdb4kNqyA3D3nVOt14bKgD/UiDfUKE1MwiV
	pOqj/S0wiJdChKW52zRAkwuQ7PtKkgI=
	=AiY9
	-----END PGP MESSAGE-----
	--11d2cbf164a9ae0dfbb310faf818762607dcfd20aa74e07c7be0eec1458d--
which is correct, and decodes correctly in neomutt.

Fixes: https://lists.sr.ht/~sircmpwn/sr.ht-discuss/%3C4uxbrlspm45s5i4bhhmqgmry374i22oqcxedtowda5zrzd7bpf2%405pyosds5owty%3E
Next