Skip to content

Commit 9161e03

Browse files
authored
feat: thumbhash (#87)
* feat: thumbhash * chore: go tidy * chore: run lint through devbox * chore: less verbose migration logging * chore: increase test timeout * fix: add worker pool to migration * fix: adjust migration * fix: tweak worker count * fix: make cloudflare not think we're getting ddos'd * chore: lint
1 parent 7183dd0 commit 9161e03

40 files changed

+1103
-133
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626

27-
- uses: actions/setup-go@v5
27+
- uses: jetify-com/[email protected]
2828
with:
29-
go-version-file: go.mod
29+
enable-cache: true
3030

31-
- uses: golangci/golangci-lint-action@v6
32-
with:
33-
version: v1.60.1
34-
args: --timeout 5m
31+
- name: Lint
32+
run: |
33+
devbox run -- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1
34+
devbox run -- $(go env GOPATH)/bin/golangci-lint run --timeout 30m
3535
3636
workflowcheck:
3737
name: Workflow Check
@@ -112,7 +112,7 @@ jobs:
112112
PGPASSWORD: REPLACE_ME
113113

114114
- name: Test
115-
run: devbox run -- go test -v -run '^TestSetup$' ./...
115+
run: devbox run -- go test -v -p 1 -timeout 1h -run '^TestSetup$' ./...
116116
env:
117117
CGO_ENABLED: 1
118118
REPO_PASETO__PUBLIC_KEY: 408c5155a389aeabf1c1b0da73ff5a3079b6aa6628e4c661b1e1ce412181cc8a

db/ent.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,7 @@ func Tx(ctx context.Context, f func(newCtx context.Context, tx *ent.Tx) error, o
148148
func EnableDebug() {
149149
debugEnabled = true
150150
}
151+
152+
func DisableDebug() {
153+
debugEnabled = false
154+
}

db/oauth.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,17 @@ func CompleteOAuthFlow(ctx context.Context, u *oauth.UserData, userAgent string)
8888
}
8989

9090
if avatarURL != "" && newUser {
91-
avatarData, err := util.LinkToWebp(ctx, avatarURL)
91+
avatarData, thumbHash, err := util.LinkToWebp(ctx, avatarURL)
9292
if err != nil {
9393
return nil, err
9494
}
9595

9696
avatarKey, err := storage.UploadUserAvatar(ctx, found.ID, bytes.NewReader(avatarData))
9797
if err == nil {
98-
if err := found.Update().SetAvatar(storage.GenerateDownloadLink(ctx, avatarKey)).Exec(ctx); err != nil {
98+
if err := found.Update().
99+
SetAvatar(storage.GenerateDownloadLink(ctx, avatarKey)).
100+
SetNillableAvatarThumbhash(util.ContainsOrNil(thumbHash)).
101+
Exec(ctx); err != nil {
99102
return nil, err
100103
}
101104
}

db/schema/mod.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (Mod) Fields() []ent.Field {
2727
field.String("short_description").MaxLen(128),
2828
field.String("full_description"),
2929
field.String("logo"),
30+
field.String("logo_thumbhash").Optional(),
3031
field.String("source_url").Optional(),
3132
field.String("creator_id"),
3233
field.Bool("approved").Default(false),

db/schema/user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func (User) Fields() []ent.Field {
2424
field.String("email").MaxLen(256),
2525
field.String("username").MaxLen(32),
2626
field.String("avatar").Optional(),
27+
field.String("avatar_thumbhash").Optional(),
2728
field.String("joined_from").Optional(),
2829
field.Bool("banned").Default(false),
2930
field.Int("rank").Default(1),

devbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"packages": [
44
55
6-
6+
77
88
99
"minio-client@2024-07-31T15-58-33Z",

devbox.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,51 +145,51 @@
145145
}
146146
}
147147
},
148-
149-
"last_modified": "2024-08-18T12:44:29Z",
150-
"resolved": "github:NixOS/nixpkgs/ff1c2669bbb4d0dd9e62cc94f0968cfa652ceec1#golangci-lint",
148+
149+
"last_modified": "2024-08-21T11:30:02Z",
150+
"resolved": "github:NixOS/nixpkgs/f132a77a82530de0d10216f09857090d324fee05#golangci-lint",
151151
"source": "devbox-search",
152-
"version": "1.60.1",
152+
"version": "1.60.2",
153153
"systems": {
154154
"aarch64-darwin": {
155155
"outputs": [
156156
{
157157
"name": "out",
158-
"path": "/nix/store/nb8a2y6dcsmhr32hlmpamw50dkdfn3wl-golangci-lint-1.60.1",
158+
"path": "/nix/store/zl8l769wimy5bsvrlcvq9f6b7465z4hx-golangci-lint-1.60.2",
159159
"default": true
160160
}
161161
],
162-
"store_path": "/nix/store/nb8a2y6dcsmhr32hlmpamw50dkdfn3wl-golangci-lint-1.60.1"
162+
"store_path": "/nix/store/zl8l769wimy5bsvrlcvq9f6b7465z4hx-golangci-lint-1.60.2"
163163
},
164164
"aarch64-linux": {
165165
"outputs": [
166166
{
167167
"name": "out",
168-
"path": "/nix/store/8112xawpm1ypp6gsz9h09ri6zjjd3m7q-golangci-lint-1.60.1",
168+
"path": "/nix/store/drgzg08jxcc50azd6bchxy6gcym2kwav-golangci-lint-1.60.2",
169169
"default": true
170170
}
171171
],
172-
"store_path": "/nix/store/8112xawpm1ypp6gsz9h09ri6zjjd3m7q-golangci-lint-1.60.1"
172+
"store_path": "/nix/store/drgzg08jxcc50azd6bchxy6gcym2kwav-golangci-lint-1.60.2"
173173
},
174174
"x86_64-darwin": {
175175
"outputs": [
176176
{
177177
"name": "out",
178-
"path": "/nix/store/zjh1bnambjwj13j9gxx0xg8hxblqacxs-golangci-lint-1.60.1",
178+
"path": "/nix/store/my7afydss5zsi4z30mzshj31bm2v5chd-golangci-lint-1.60.2",
179179
"default": true
180180
}
181181
],
182-
"store_path": "/nix/store/zjh1bnambjwj13j9gxx0xg8hxblqacxs-golangci-lint-1.60.1"
182+
"store_path": "/nix/store/my7afydss5zsi4z30mzshj31bm2v5chd-golangci-lint-1.60.2"
183183
},
184184
"x86_64-linux": {
185185
"outputs": [
186186
{
187187
"name": "out",
188-
"path": "/nix/store/il2a9jd3kbh91yxbm90z0am3c34gfxgf-golangci-lint-1.60.1",
188+
"path": "/nix/store/rp23zfccxkvzqphhrx0sp2pz682v89r8-golangci-lint-1.60.2",
189189
"default": true
190190
}
191191
],
192-
"store_path": "/nix/store/il2a9jd3kbh91yxbm90z0am3c34gfxgf-golangci-lint-1.60.1"
192+
"store_path": "/nix/store/rp23zfccxkvzqphhrx0sp2pz682v89r8-golangci-lint-1.60.2"
193193
}
194194
}
195195
},

generated/conv/mod.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/conv/user.go

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/ent/internal/schema.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)