Skip to content

Commit e300b2a

Browse files
committed
chore: updated to go 1.26
1 parent 46ee4d6 commit e300b2a

File tree

15 files changed

+1488
-1705
lines changed

15 files changed

+1488
-1705
lines changed

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ After generating or editing code, you must always refactor your changes using we
4242
4343
## High-Level Architecture
4444
- **Frontend:** SvelteKit 2 (Svelte 5) with Vite, Tailwind CSS v4, and shadcn-svelte; loaders build absolute API URLs using `PUBLIC_API_URL`.
45-
- **Backend:** Go 1.25 Fiber API using Zap logging, GORM (MySQL driver) targeting MariaDB, shared middleware for compression, CORS, ETag, and request limiting, serving JSON under `/api/*`.
45+
- **Backend:** Go 1.26 Fiber API using Zap logging, GORM (MySQL driver) targeting MariaDB, shared middleware for compression, CORS, ETag, and request limiting, serving JSON under `/api/*`.
4646
- **Workers:** Goroutine workers managed by `backend-go/workers/manager.go`; enablement and intervals come from env vars and statuses persist in the `workers` table.
4747
- **Fansly Integration:** `backend-go/fansly/client.go` centralizes authentication, retries, and global rate limiting for all Fansly requests.
4848
- **Schema Source of Truth:** `backend-go/models` combined with `backend-go/database/migrate.go` drives AutoMigrate; never mutate the database outside this layer.
@@ -74,7 +74,7 @@ After generating or editing code, you must always refactor your changes using we
7474
- `frontend/.env.example`
7575

7676
### backend-go
77-
- Language: Go (1.25+)
77+
- Language: Go (1.26+)
7878
- Framework/runtime: Fiber v2 with Zap logging
7979
- Package manager: Go modules
8080
- Important Packages: `github.com/gofiber/fiber/v2`, `gorm.io/gorm`, `gorm.io/driver/mysql`, `go.uber.org/zap`, `github.com/joho/godotenv`

Taskfile.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,25 @@ tasks:
2525
- air
2626
- cmd: kill -9 $(lsof -t -i:3001)
2727
ignore_error: true
28+
29+
install:
30+
desc: Install the dependencies
31+
cmds:
32+
- pnpm install -r
33+
- |
34+
find . -name "go.mod" -type f | grep -v "/vendor/" | while read -r modfile; do
35+
dir=$(dirname "$modfile")
36+
echo "Installing in $dir"
37+
(cd "$dir" && go mod download)
38+
done
39+
40+
update:
41+
desc: Update the dependencies
42+
cmds:
43+
- pnpm update -r
44+
- |
45+
find . -name "go.mod" -type f | grep -v "/vendor/" | while read -r modfile; do
46+
dir=$(dirname "$modfile")
47+
echo "Updating in $dir"
48+
(cd "$dir" && go get -u ./... && go mod tidy)
49+
done

backend-go/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM golang:1.25-alpine AS builder
2+
FROM golang:1.26-alpine AS builder
33

44
# Install build dependencies
55
RUN apk add --no-cache git
@@ -41,4 +41,4 @@ USER appuser
4141
EXPOSE 3000
4242

4343
# Run the application
44-
CMD ["./main"]
44+
CMD ["./main"]

backend-go/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Go implementation of the FToolbox backend API.
44

55
## Prerequisites
66

7-
- Go 1.21+
7+
- Go 1.26+
88
- MariaDB
99
- Air (for hot reloading): `go install github.com/cosmtrek/air@latest`
1010

backend-go/fansly/client.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net/http"
1010
"os"
1111
"strconv"
12+
"strings"
1213
"time"
1314

1415
"ftoolbox/ratelimit"
@@ -158,8 +159,8 @@ func (c *Client) doRequest(ctx context.Context, url string) ([]byte, error) {
158159

159160
// FanslyResponse represents the generic API response structure
160161
type FanslyResponse struct {
161-
Success bool `json:"success"`
162-
Response interface{} `json:"response,omitempty"`
162+
Success bool `json:"success"`
163+
Response any `json:"response,omitempty"`
163164
}
164165

165166
// FanslyTag represents a tag from the Fansly API
@@ -175,8 +176,8 @@ type FanslyTag struct {
175176

176177
// TagResponseData represents the tag response data structure
177178
type TagResponseData struct {
178-
MediaOfferSuggestionTag *FanslyTag `json:"mediaOfferSuggestionTag,omitempty"`
179-
AggregationData map[string]interface{} `json:"aggregationData,omitempty"`
179+
MediaOfferSuggestionTag *FanslyTag `json:"mediaOfferSuggestionTag,omitempty"`
180+
AggregationData map[string]any `json:"aggregationData,omitempty"`
180181
}
181182

182183
// GetTagWithContext fetches a single tag by name with context
@@ -213,7 +214,7 @@ type FanslyPost struct {
213214
FypFlags *int `json:"fypFlags,omitempty"`
214215
InReplyTo *string `json:"inReplyTo,omitempty"`
215216
InReplyToRoot *string `json:"inReplyToRoot,omitempty"`
216-
ReplyPermissionFlags interface{} `json:"replyPermissionFlags,omitempty"`
217+
ReplyPermissionFlags any `json:"replyPermissionFlags,omitempty"`
217218
ExpiresAt *int64 `json:"expiresAt,omitempty"`
218219
LikeCount int `json:"likeCount,omitempty"`
219220
ReplyCount int `json:"replyCount,omitempty"`
@@ -258,28 +259,28 @@ type SuggestionsResponseData struct {
258259
MediaOfferSuggestions []MediaOfferSuggestion `json:"mediaOfferSuggestions,omitempty"`
259260
AggregationData *struct {
260261
Accounts []FanslyAccount `json:"accounts,omitempty"`
261-
AccountMedia []interface{} `json:"accountMedia,omitempty"`
262-
AccountMediaBundles []interface{} `json:"accountMediaBundles,omitempty"`
262+
AccountMedia []any `json:"accountMedia,omitempty"`
263+
AccountMediaBundles []any `json:"accountMediaBundles,omitempty"`
263264
Posts []FanslyPost `json:"posts,omitempty"`
264-
Tips []interface{} `json:"tips,omitempty"`
265-
TipGoals []interface{} `json:"tipGoals,omitempty"`
266-
Stories []interface{} `json:"stories,omitempty"`
265+
Tips []any `json:"tips,omitempty"`
266+
TipGoals []any `json:"tipGoals,omitempty"`
267+
Stories []any `json:"stories,omitempty"`
267268
} `json:"aggregationData,omitempty"`
268269
}
269270

270271
// GetSuggestionsData fetches all data from the suggestions endpoint with full parameter control
271272
func (c *Client) GetSuggestionsData(ctx context.Context, tagIDs []string, before, after string, limit, offset int) (*SuggestionsResponseData, error) {
272273
// Build tag IDs string
273-
tagIDsStr := ""
274+
var tagIDsStr strings.Builder
274275
for i, id := range tagIDs {
275276
if i > 0 {
276-
tagIDsStr += ","
277+
tagIDsStr.WriteString(",")
277278
}
278-
tagIDsStr += id
279+
tagIDsStr.WriteString(id)
279280
}
280281

281282
url := fmt.Sprintf("%s/contentdiscovery/media/suggestionsnew?before=%s&after=%s&tagIds=%s&limit=%d&offset=%d&ngsw-bypass=true",
282-
baseURL, before, after, tagIDsStr, limit, offset)
283+
baseURL, before, after, tagIDsStr.String(), limit, offset)
283284

284285
body, err := c.doRequest(ctx, url)
285286
if err != nil {
@@ -304,15 +305,15 @@ func (c *Client) GetAccountsWithContext(ctx context.Context, accountIDs []string
304305
}
305306

306307
// Build comma-separated list of account IDs
307-
idsParam := ""
308+
var idsParam strings.Builder
308309
for i, id := range accountIDs {
309310
if i > 0 {
310-
idsParam += ","
311+
idsParam.WriteString(",")
311312
}
312-
idsParam += id
313+
idsParam.WriteString(id)
313314
}
314315

315-
url := fmt.Sprintf("%s/account?ids=%s&ngsw-bypass=true", baseURL, idsParam)
316+
url := fmt.Sprintf("%s/account?ids=%s&ngsw-bypass=true", baseURL, idsParam.String())
316317

317318
body, err := c.doRequest(ctx, url)
318319
if err != nil {
@@ -366,7 +367,7 @@ func (c *Client) GetAccountByUsername(ctx context.Context, username string) (*Fa
366367
}
367368

368369
// ParseFanslyTimestamp converts Fansly timestamp (milliseconds) to time.Time
369-
func ParseFanslyTimestamp(timestamp interface{}) time.Time {
370+
func ParseFanslyTimestamp(timestamp any) time.Time {
370371
switch v := timestamp.(type) {
371372
case float64:
372373
// Convert milliseconds to seconds

backend-go/go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
module ftoolbox
22

3-
go 1.25.1
3+
go 1.26.0
44

55
require (
6-
github.com/gofiber/fiber/v2 v2.52.9
6+
github.com/gofiber/fiber/v2 v2.52.11
77
github.com/joho/godotenv v1.5.1
8-
go.uber.org/zap v1.27.0
8+
go.uber.org/zap v1.27.1
99
gorm.io/driver/mysql v1.6.0
10-
gorm.io/gorm v1.31.0
10+
gorm.io/gorm v1.31.1
1111
)
1212

1313
require (
1414
filippo.io/edwards25519 v1.1.0 // indirect
1515
github.com/andybalholm/brotli v1.2.0 // indirect
16+
github.com/clipperhouse/uax29/v2 v2.6.0 // indirect
1617
github.com/go-sql-driver/mysql v1.9.3 // indirect
1718
github.com/google/uuid v1.6.0 // indirect
1819
github.com/jinzhu/inflection v1.0.0 // indirect
1920
github.com/jinzhu/now v1.1.5 // indirect
20-
github.com/klauspost/compress v1.18.0 // indirect
21+
github.com/klauspost/compress v1.18.4 // indirect
2122
github.com/mattn/go-colorable v0.1.14 // indirect
2223
github.com/mattn/go-isatty v0.0.20 // indirect
23-
github.com/mattn/go-runewidth v0.0.16 // indirect
24+
github.com/mattn/go-runewidth v0.0.19 // indirect
2425
github.com/philhofer/fwd v1.2.0 // indirect
25-
github.com/rivo/uniseg v0.4.7 // indirect
26-
github.com/tinylib/msgp v1.4.0 // indirect
26+
github.com/tinylib/msgp v1.6.3 // indirect
2727
github.com/valyala/bytebufferpool v1.0.0 // indirect
28-
github.com/valyala/fasthttp v1.66.0 // indirect
28+
github.com/valyala/fasthttp v1.69.0 // indirect
2929
go.uber.org/multierr v1.11.0 // indirect
30-
golang.org/x/sys v0.36.0 // indirect
31-
golang.org/x/text v0.29.0 // indirect
30+
golang.org/x/sys v0.41.0 // indirect
31+
golang.org/x/text v0.34.0 // indirect
3232
)

backend-go/go.sum

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
22
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
33
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
44
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
5+
github.com/clipperhouse/uax29/v2 v2.6.0 h1:z0cDbUV+aPASdFb2/ndFnS9ts/WNXgTNNGFoKXuhpos=
6+
github.com/clipperhouse/uax29/v2 v2.6.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
57
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
68
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
79
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
810
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
9-
github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw=
10-
github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
11+
github.com/gofiber/fiber/v2 v2.52.11 h1:5f4yzKLcBcF8ha1GQTWB+mpblWz3Vz6nSAbTL31HkWs=
12+
github.com/gofiber/fiber/v2 v2.52.11/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
1113
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
1214
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1315
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
@@ -16,45 +18,42 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
1618
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
1719
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
1820
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
19-
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
20-
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
21+
github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c=
22+
github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
2123
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
2224
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
2325
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
2426
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
25-
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
26-
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
27+
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
28+
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
2729
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
2830
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
2931
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3032
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
31-
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
32-
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
33-
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
3433
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
3534
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
36-
github.com/tinylib/msgp v1.4.0 h1:SYOeDRiydzOw9kSiwdYp9UcBgPFtLU2WDHaJXyHruf8=
37-
github.com/tinylib/msgp v1.4.0/go.mod h1:cvjFkb4RiC8qSBOPMGPSzSAx47nAsfhLVTCZZNuHv5o=
35+
github.com/tinylib/msgp v1.6.3 h1:bCSxiTz386UTgyT1i0MSCvdbWjVW+8sG3PjkGsZQt4s=
36+
github.com/tinylib/msgp v1.6.3/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
3837
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
3938
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
40-
github.com/valyala/fasthttp v1.66.0 h1:M87A0Z7EayeyNaV6pfO3tUTUiYO0dZfEJnRGXTVNuyU=
41-
github.com/valyala/fasthttp v1.66.0/go.mod h1:Y4eC+zwoocmXSVCB1JmhNbYtS7tZPRI2ztPB72EVObs=
39+
github.com/valyala/fasthttp v1.69.0 h1:fNLLESD2SooWeh2cidsuFtOcrEi4uB4m1mPrkJMZyVI=
40+
github.com/valyala/fasthttp v1.69.0/go.mod h1:4wA4PfAraPlAsJ5jMSqCE2ug5tqUPwKXxVj8oNECGcw=
4241
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
4342
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
4443
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
4544
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
4645
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
4746
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
48-
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
49-
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
47+
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
48+
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
5049
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
51-
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
52-
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
53-
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
54-
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
50+
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
51+
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
52+
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
53+
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
5554
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
5655
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5756
gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
5857
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
59-
gorm.io/gorm v1.31.0 h1:0VlycGreVhK7RF/Bwt51Fk8v0xLiiiFdbGDPIZQ7mJY=
60-
gorm.io/gorm v1.31.0/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
58+
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
59+
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=

backend-go/handlers/creator_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ func (h *CreatorHandler) GetCreators(c *fiber.Ctx) error {
200200
}
201201

202202
// For non-history responses, we need to convert creators to proper format
203-
creatorsData := make([]map[string]interface{}, len(creators))
203+
creatorsData := make([]map[string]any, len(creators))
204204
for i, creator := range creators {
205-
creatorsData[i] = map[string]interface{}{
205+
creatorsData[i] = map[string]any{
206206
"id": creator.ID,
207207
"username": creator.Username,
208208
"displayName": creator.DisplayName,

backend-go/handlers/tag_handler.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,7 @@ func (h *TagHandler) GetTags(c *fiber.Ctx) error {
178178
var allHistories []models.TagHistory
179179

180180
for i := 0; i < len(tagIDs); i += batchSize {
181-
end := i + batchSize
182-
if end > len(tagIDs) {
183-
end = len(tagIDs)
184-
}
181+
end := min(i+batchSize, len(tagIDs))
185182
batchIDs := tagIDs[i:end]
186183

187184
// Build base query for this batch
@@ -233,7 +230,7 @@ func (h *TagHandler) GetTags(c *fiber.Ctx) error {
233230
PostCount: tag.PostCount,
234231
Rank: tag.Rank,
235232
Heat: 0,
236-
FanslyCreatedAt: ptr(timeToUnix(tag.FanslyCreatedAt)),
233+
FanslyCreatedAt: new(timeToUnix(tag.FanslyCreatedAt)),
237234
LastCheckedAt: timeToUnixPtr(tag.LastCheckedAt),
238235
LastUsedForDiscovery: timeToUnixPtr(tag.LastUsedForDiscovery),
239236
IsDeleted: tag.IsDeleted,
@@ -306,22 +303,22 @@ func (h *TagHandler) GetTags(c *fiber.Ctx) error {
306303

307304
// For non-history responses, we need to convert tags to proper format
308305

309-
tagsData := make([]map[string]interface{}, len(tags))
306+
tagsData := make([]map[string]any, len(tags))
310307
for i, tag := range tags {
311308
// Show 0 view count for deleted tags
312309
viewCount := tag.ViewCount
313310
if tag.IsDeleted {
314311
viewCount = 0
315312
}
316313

317-
tagsData[i] = map[string]interface{}{
314+
tagsData[i] = map[string]any{
318315
"id": tag.ID,
319316
"tag": tag.Tag,
320317
"viewCount": viewCount,
321318
"postCount": tag.PostCount,
322319
"rank": tag.Rank,
323320
"heat": 0,
324-
"fanslyCreatedAt": ptr(timeToUnix(tag.FanslyCreatedAt)),
321+
"fanslyCreatedAt": new(timeToUnix(tag.FanslyCreatedAt)),
325322
"lastCheckedAt": timeToUnixPtr(tag.LastCheckedAt),
326323
"lastUsedForDiscovery": timeToUnixPtr(tag.LastUsedForDiscovery),
327324
"isDeleted": tag.IsDeleted,
@@ -620,10 +617,7 @@ func (h *TagHandler) GetRelatedTags(c *fiber.Ctx) error {
620617

621618
// Smart mode: per-source normalization + coverage weighting
622619
// minCoverage: default to ceil(40% of inputs), bounded to [1, len(inputs)]
623-
minCoverageDefault := int(math.Ceil(0.4 * float64(len(srcIDs))))
624-
if minCoverageDefault < 1 {
625-
minCoverageDefault = 1
626-
}
620+
minCoverageDefault := max(int(math.Ceil(0.4*float64(len(srcIDs)))), 1)
627621
if minCoverageDefault > len(srcIDs) {
628622
minCoverageDefault = len(srcIDs)
629623
}
@@ -724,9 +718,9 @@ func (h *TagHandler) GetRelatedTags(c *fiber.Ctx) error {
724718
}
725719
out := scoredRows[:limit]
726720

727-
resp := make([]map[string]interface{}, 0, len(out))
721+
resp := make([]map[string]any, 0, len(out))
728722
for _, r := range out {
729-
resp = append(resp, map[string]interface{}{
723+
resp = append(resp, map[string]any{
730724
"id": r.ID,
731725
"tag": r.Tag,
732726
"normScore": r.NormAvg,
@@ -751,13 +745,14 @@ func timeToUnixPtr(t *time.Time) *int64 {
751745
if t == nil {
752746
return nil
753747
}
754-
return ptr(t.Unix())
748+
return new(t.Unix())
755749
}
756750

757751
func timeToUnix(t time.Time) int64 {
758752
return t.Unix()
759753
}
760754

755+
//go:fix inline
761756
func ptr[T any](v T) *T {
762-
return &v
757+
return new(v)
763758
}

0 commit comments

Comments
 (0)