forked from mirrors/pronouns.cc
Compare commits
No commits in common. "main" and "feature/preference-cheatsheet" have entirely different histories.
main
...
feature/pr
63 changed files with 101 additions and 325 deletions
|
@ -1,13 +0,0 @@
|
|||
when:
|
||||
branch:
|
||||
exclude: stable
|
||||
|
||||
steps:
|
||||
check:
|
||||
image: golang:alpine
|
||||
commands:
|
||||
- apk update && apk add curl vips-dev build-base
|
||||
- make backend
|
||||
# Install golangci-lint
|
||||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
|
||||
- golangci-lint run
|
|
@ -1,20 +0,0 @@
|
|||
when:
|
||||
branch:
|
||||
exclude: stable
|
||||
|
||||
steps:
|
||||
check:
|
||||
image: node
|
||||
directory: frontend
|
||||
environment: # SvelteKit expects these in the environment during build time.
|
||||
- PRIVATE_SENTRY_DSN=
|
||||
- PUBLIC_BASE_URL=http://pronouns.localhost
|
||||
- PUBLIC_MEDIA_URL=http://pronouns.localhost/media
|
||||
- PUBLIC_SHORT_BASE=http://prns.localhost
|
||||
- PUBLIC_HCAPTCHA_SITEKEY=non_existent_sitekey
|
||||
commands:
|
||||
- corepack enable
|
||||
- pnpm install
|
||||
- pnpm check
|
||||
- pnpm lint
|
||||
- pnpm build
|
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@ all: generate backend frontend
|
|||
|
||||
.PHONY: backend
|
||||
backend:
|
||||
go build -v -o pronouns -ldflags="-buildid= -X codeberg.org/pronounscc/pronouns.cc/backend/server.Revision=`git rev-parse --short HEAD` -X codeberg.org/pronounscc/pronouns.cc/backend/server.Tag=`git describe --tags --long --always`" .
|
||||
go build -v -o pronouns -ldflags="-buildid= -X codeberg.org/pronounscc/pronouns.cc/backend/server.Revision=`git rev-parse --short HEAD` -X codeberg.org/pronounscc/pronouns.cc/backend/server.Tag=`git describe --tags --long`" .
|
||||
|
||||
.PHONY: generate
|
||||
generate:
|
||||
|
|
|
@ -79,7 +79,7 @@ func (db *DB) CreateExport(ctx context.Context, userID xid.ID, filename string,
|
|||
return de, errors.Wrap(err, "building query")
|
||||
}
|
||||
|
||||
err = pgxscan.Get(ctx, db, &de, sql, args...)
|
||||
pgxscan.Get(ctx, db, &de, sql, args...)
|
||||
if err != nil {
|
||||
return de, errors.Wrap(err, "executing sql")
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ func (f FediverseApp) ClientConfig() *oauth2.Config {
|
|||
}
|
||||
|
||||
func (f FediverseApp) MastodonCompatible() bool {
|
||||
return f.InstanceType == "mastodon" || f.InstanceType == "pleroma" || f.InstanceType == "akkoma" || f.InstanceType == "incestoma" || f.InstanceType == "pixelfed" || f.InstanceType == "gotosocial"
|
||||
return f.InstanceType == "mastodon" || f.InstanceType == "pleroma" || f.InstanceType == "akkoma" || f.InstanceType == "pixelfed" || f.InstanceType == "gotosocial"
|
||||
}
|
||||
|
||||
func (f FediverseApp) Misskey() bool {
|
||||
return f.InstanceType == "misskey" || f.InstanceType == "foundkey" || f.InstanceType == "calckey" || f.InstanceType == "firefish" || f.InstanceType == "sharkey"
|
||||
return f.InstanceType == "misskey" || f.InstanceType == "foundkey" || f.InstanceType == "calckey" || f.InstanceType == "firefish"
|
||||
}
|
||||
|
||||
const ErrNoInstanceApp = errors.Sentinel("instance doesn't have an app")
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/base64"
|
||||
"time"
|
||||
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/log"
|
||||
"emperror.dev/errors"
|
||||
"github.com/georgysavva/scany/v2/pgxscan"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
@ -44,12 +43,7 @@ func (db *DB) CreateInvite(ctx context.Context, userID xid.ID) (i Invite, err er
|
|||
if err != nil {
|
||||
return i, errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
var maxInvites, inviteCount int
|
||||
err = tx.QueryRow(ctx, "SELECT max_invites FROM users WHERE id = $1", userID).Scan(&maxInvites)
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"time"
|
||||
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/common"
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/log"
|
||||
"emperror.dev/errors"
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/georgysavva/scany/v2/pgxscan"
|
||||
|
@ -288,12 +287,7 @@ func (db *DB) RerollMemberSID(ctx context.Context, userID, memberID xid.ID) (new
|
|||
if err != nil {
|
||||
return "", errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
sql, args, err := sq.Update("members").
|
||||
Set("sid", squirrel.Expr("find_free_member_sid()")).
|
||||
|
|
|
@ -26,8 +26,7 @@ var Command = &cli.Command{
|
|||
func run(c *cli.Context) error {
|
||||
// initialize sentry
|
||||
if dsn := os.Getenv("SENTRY_DSN"); dsn != "" {
|
||||
// We don't need to check the error here--it's fine if no DSN is set.
|
||||
_ = sentry.Init(sentry.ClientOptions{
|
||||
sentry.Init(sentry.ClientOptions{
|
||||
Dsn: dsn,
|
||||
Debug: os.Getenv("DEBUG") == "true",
|
||||
Release: server.Tag,
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"emperror.dev/errors"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/mediocregopher/radix/v4"
|
||||
"github.com/rs/xid"
|
||||
"golang.org/x/oauth2"
|
||||
|
@ -292,12 +291,7 @@ func (s *Server) discordSignup(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
du := new(discordgo.User)
|
||||
err = s.DB.GetJSON(ctx, "discord:"+req.Ticket, &du)
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
||||
"emperror.dev/errors"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/mediocregopher/radix/v4"
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
@ -320,12 +319,7 @@ func (s *Server) mastodonSignup(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
mu := new(partialMastodonAccount)
|
||||
err = s.DB.GetJSON(ctx, "mastodon:"+req.Ticket, &mu)
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
||||
"emperror.dev/errors"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/mediocregopher/radix/v4"
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
@ -248,12 +247,7 @@ func (s *Server) misskeySignup(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
mu := new(partialMisskeyAccount)
|
||||
err = s.DB.GetJSON(ctx, "misskey:"+req.Ticket, &mu)
|
||||
|
|
|
@ -68,10 +68,13 @@ func (s *Server) noAppFediverseURL(ctx context.Context, w http.ResponseWriter, r
|
|||
case "iceshrimp":
|
||||
softwareName = "firefish"
|
||||
fallthrough
|
||||
case "misskey", "foundkey", "calckey", "firefish", "sharkey":
|
||||
case "misskey", "foundkey", "calckey", "firefish":
|
||||
return s.noAppMisskeyURL(ctx, w, r, softwareName, instance)
|
||||
case "mastodon", "pleroma", "akkoma", "incestoma", "pixelfed", "gotosocial":
|
||||
case "mastodon", "pleroma", "akkoma", "pixelfed", "gotosocial":
|
||||
case "glitchcafe", "hometown":
|
||||
// plural.cafe (potentially other instances too?) runs Mastodon but changes the software name
|
||||
// Hometown is a lightweight fork of Mastodon so we can just treat it the same
|
||||
// changing it back to mastodon here for consistency
|
||||
softwareName = "mastodon"
|
||||
default:
|
||||
return server.APIError{Code: server.ErrUnsupportedInstance}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
||||
"emperror.dev/errors"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/mediocregopher/radix/v4"
|
||||
"github.com/rs/xid"
|
||||
"golang.org/x/oauth2"
|
||||
|
@ -295,12 +294,7 @@ func (s *Server) googleSignup(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
gu := new(partialGoogleUser)
|
||||
err = s.DB.GetJSON(ctx, "google:"+req.Ticket, &gu)
|
||||
|
|
|
@ -185,7 +185,7 @@ func (s *Server) oauthURLs(w http.ResponseWriter, r *http.Request) error {
|
|||
if googleOAuthConfig.ClientID != "" {
|
||||
googleCfg := googleOAuthConfig
|
||||
googleCfg.RedirectURL = req.CallbackDomain + "/auth/login/google"
|
||||
resp.Google = googleCfg.AuthCodeURL(state) + "&prompt=select_account"
|
||||
resp.Google = googleCfg.AuthCodeURL(state)
|
||||
}
|
||||
|
||||
render.JSON(w, r, resp)
|
||||
|
|
|
@ -5,11 +5,9 @@ import (
|
|||
"time"
|
||||
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/db"
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/log"
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
||||
"emperror.dev/errors"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
||||
|
@ -65,12 +63,7 @@ func (s *Server) deleteToken(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
err = s.DB.InvalidateAllTokens(ctx, tx, claims.UserID)
|
||||
if err != nil {
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
||||
"emperror.dev/errors"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/mediocregopher/radix/v4"
|
||||
"github.com/rs/xid"
|
||||
"golang.org/x/oauth2"
|
||||
|
@ -328,12 +327,7 @@ func (s *Server) tumblrSignup(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
tui := new(tumblrUserInfo)
|
||||
err = s.DB.GetJSON(ctx, "tumblr:"+req.Ticket, &tui)
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
||||
"emperror.dev/errors"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
type CreateMemberRequest struct {
|
||||
|
@ -120,12 +119,7 @@ func (s *Server) createMember(w http.ResponseWriter, r *http.Request) (err error
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "starting transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
m, err := s.DB.CreateMember(ctx, tx, claims.UserID, cmr.Name, cmr.DisplayName, cmr.Bio, cmr.Links)
|
||||
if err != nil {
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
"emperror.dev/errors"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
||||
|
@ -247,12 +246,7 @@ func (s *Server) patchMember(w http.ResponseWriter, r *http.Request) error {
|
|||
log.Errorf("creating transaction: %v", err)
|
||||
return errors.Wrap(err, "creating transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
m, err = s.DB.UpdateMember(ctx, tx, m.ID, req.Name, req.DisplayName, req.Bio, req.Unlisted, req.Links, avatarHash)
|
||||
if err != nil {
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"emperror.dev/errors"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
type resolveReportRequest struct {
|
||||
|
@ -44,12 +43,7 @@ func (s *Server) resolveReport(w http.ResponseWriter, r *http.Request) error {
|
|||
log.Errorf("creating transaction: %v", err)
|
||||
return errors.Wrap(err, "creating transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
report, err := s.DB.Report(ctx, tx, id)
|
||||
if err != nil {
|
||||
|
|
|
@ -3,11 +3,9 @@ package user
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/log"
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
||||
"emperror.dev/errors"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
func (s *Server) deleteUser(w http.ResponseWriter, r *http.Request) error {
|
||||
|
@ -22,12 +20,7 @@ func (s *Server) deleteUser(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "creating transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
err = s.DB.DeleteUser(ctx, tx, claims.UserID, true, "")
|
||||
if err != nil {
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
"emperror.dev/errors"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
||||
|
@ -81,12 +80,7 @@ func (s *Server) postUserFlag(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "starting transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
flag, err := s.DB.CreateFlag(ctx, tx, claims.UserID, req.Name, req.Description)
|
||||
if err != nil {
|
||||
|
@ -198,12 +192,7 @@ func (s *Server) patchUserFlag(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "beginning transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
flag, err = s.DB.EditFlag(ctx, tx, flag.ID, req.Name, req.Description, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"emperror.dev/errors"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
||||
|
@ -222,12 +221,7 @@ func (s *Server) patchUser(w http.ResponseWriter, r *http.Request) error {
|
|||
log.Errorf("creating transaction: %v", err)
|
||||
return errors.Wrap(err, "creating transaction")
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
// update username
|
||||
if req.Username != nil && *req.Username != u.Username {
|
||||
|
|
|
@ -100,23 +100,23 @@ func New() (*Server, error) {
|
|||
|
||||
// set scopes
|
||||
// users
|
||||
_ = rateLimiter.Scope("GET", "/users/*", 60)
|
||||
_ = rateLimiter.Scope("PATCH", "/users/@me", 10)
|
||||
rateLimiter.Scope("GET", "/users/*", 60)
|
||||
rateLimiter.Scope("PATCH", "/users/@me", 10)
|
||||
|
||||
// members
|
||||
_ = rateLimiter.Scope("GET", "/users/*/members", 60)
|
||||
_ = rateLimiter.Scope("GET", "/users/*/members/*", 60)
|
||||
rateLimiter.Scope("GET", "/users/*/members", 60)
|
||||
rateLimiter.Scope("GET", "/users/*/members/*", 60)
|
||||
|
||||
_ = rateLimiter.Scope("POST", "/members", 10)
|
||||
_ = rateLimiter.Scope("GET", "/members/*", 60)
|
||||
_ = rateLimiter.Scope("PATCH", "/members/*", 20)
|
||||
_ = rateLimiter.Scope("DELETE", "/members/*", 5)
|
||||
rateLimiter.Scope("POST", "/members", 10)
|
||||
rateLimiter.Scope("GET", "/members/*", 60)
|
||||
rateLimiter.Scope("PATCH", "/members/*", 20)
|
||||
rateLimiter.Scope("DELETE", "/members/*", 5)
|
||||
|
||||
// auth
|
||||
_ = rateLimiter.Scope("*", "/auth/*", 20)
|
||||
_ = rateLimiter.Scope("*", "/auth/tokens", 10)
|
||||
_ = rateLimiter.Scope("*", "/auth/invites", 10)
|
||||
_ = rateLimiter.Scope("POST", "/auth/discord/*", 10)
|
||||
rateLimiter.Scope("*", "/auth/*", 20)
|
||||
rateLimiter.Scope("*", "/auth/tokens", 10)
|
||||
rateLimiter.Scope("*", "/auth/invites", 10)
|
||||
rateLimiter.Scope("POST", "/auth/discord/*", 10)
|
||||
|
||||
s.Router.Use(rateLimiter.Handler())
|
||||
|
||||
|
|
|
@ -17,15 +17,4 @@ module.exports = {
|
|||
es2017: true,
|
||||
node: true,
|
||||
},
|
||||
rules: {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
argsIgnorePattern: "^_",
|
||||
destructuredArrayIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
25
frontend/src/app.d.ts
vendored
25
frontend/src/app.d.ts
vendored
|
@ -1,19 +1,38 @@
|
|||
// See https://kit.svelte.dev/docs/types#app
|
||||
|
||||
import type { ErrorCode } from "$lib/api/entities";
|
||||
import type { APIError, ErrorCode } from "$lib/api/entities";
|
||||
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
interface Error {
|
||||
type Error = {
|
||||
code: ErrorCode;
|
||||
message?: string | undefined;
|
||||
details?: string | undefined;
|
||||
}
|
||||
} | APIError
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "svelte-hcaptcha" {
|
||||
import type { SvelteComponent } from "svelte";
|
||||
|
||||
export interface HCaptchaProps {
|
||||
sitekey?: string;
|
||||
apihost?: string;
|
||||
hl?: string;
|
||||
reCaptchaCompat?: boolean;
|
||||
theme?: CaptchaTheme;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
declare class HCaptcha extends SvelteComponent {
|
||||
$$prop_def: HCaptchaProps;
|
||||
}
|
||||
|
||||
export default HCaptcha;
|
||||
}
|
||||
|
||||
export {};
|
||||
|
|
|
@ -2,9 +2,7 @@ import { PRIVATE_SENTRY_DSN } from "$env/static/private";
|
|||
import * as Sentry from "@sentry/node";
|
||||
import type { HandleServerError } from "@sveltejs/kit";
|
||||
|
||||
if (PRIVATE_SENTRY_DSN) {
|
||||
Sentry.init({ dsn: PRIVATE_SENTRY_DSN });
|
||||
}
|
||||
Sentry.init({ dsn: PRIVATE_SENTRY_DSN });
|
||||
|
||||
export const handleError = (({ error, event }) => {
|
||||
console.log(error);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-unused-vars */
|
||||
import { PUBLIC_BASE_URL, PUBLIC_MEDIA_URL } from "$env/static/public";
|
||||
|
||||
export const MAX_MEMBERS = 500;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
export let urls: string[];
|
||||
export let alt: string;
|
||||
export let width = 300;
|
||||
export let lazyLoad = false;
|
||||
|
||||
const contentTypeFor = (url: string) => {
|
||||
if (url.endsWith(".webp")) {
|
||||
|
@ -32,7 +31,6 @@
|
|||
src={urls[0] || defaultAvatars[0]}
|
||||
{alt}
|
||||
class="rounded-circle img-fluid"
|
||||
loading={lazyLoad ? "lazy" : "eager"}
|
||||
/>
|
||||
</picture>
|
||||
{:else}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
export let user: User;
|
||||
export let member: PartialMember & {
|
||||
unlisted?: boolean;
|
||||
unlisted?: boolean
|
||||
};
|
||||
|
||||
let pronouns: string | undefined;
|
||||
|
@ -46,18 +46,13 @@
|
|||
|
||||
<div>
|
||||
<a href="/@{user.name}/{member.name}">
|
||||
<FallbackImage
|
||||
urls={memberAvatars(member)}
|
||||
width={200}
|
||||
lazyLoad
|
||||
alt="Avatar for {member.name}"
|
||||
/>
|
||||
<FallbackImage urls={memberAvatars(member)} width={200} alt="Avatar for {member.name}" />
|
||||
</a>
|
||||
<p class="m-2">
|
||||
<a class="text-reset fs-5 text-break" href="/@{user.name}/{member.name}">
|
||||
{member.display_name ?? member.name}
|
||||
{#if member.unlisted === true}
|
||||
<span bind:this={iconElement} tabindex={0}><Icon name="lock" /></span>
|
||||
<span bind:this={iconElement} tabindex={0}><Icon name="lock"/></span>
|
||||
<Tooltip target={iconElement} placement="top">This member is hidden</Tooltip>
|
||||
{/if}
|
||||
</a>
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
const resp = await apiFetchClient<Settings>(
|
||||
"/users/@me/settings",
|
||||
"PATCH",
|
||||
// If this function is run, notice will always be non-null
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
{ read_global_notice: data.notice!.id },
|
||||
2,
|
||||
);
|
||||
|
|
|
@ -11,7 +11,7 @@ export const load = async ({ params }) => {
|
|||
return resp;
|
||||
} catch (e) {
|
||||
if ((e as APIError).code === ErrorCode.UserNotFound) {
|
||||
error(404, e as App.Error);
|
||||
error(404, e as APIError);
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import {
|
||||
Alert,
|
||||
Badge,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
Icon,
|
||||
|
@ -14,7 +15,7 @@
|
|||
ModalFooter,
|
||||
Tooltip,
|
||||
} from "@sveltestrap/sveltestrap";
|
||||
import { DateTime, FixedOffsetZone } from "luxon";
|
||||
import { DateTime, Duration, FixedOffsetZone, Zone } from "luxon";
|
||||
import FieldCard from "$lib/components/FieldCard.svelte";
|
||||
import PronounLink from "$lib/components/PronounLink.svelte";
|
||||
import PartialMemberCard from "$lib/components/PartialMemberCard.svelte";
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
<script lang="ts">
|
||||
import type {
|
||||
CustomPreferences,
|
||||
CustomPreference,
|
||||
Field,
|
||||
FieldEntry,
|
||||
Pronoun,
|
||||
} from "$lib/api/entities";
|
||||
import type { CustomPreferences, Field, FieldEntry, Pronoun } from "$lib/api/entities";
|
||||
import defaultPreferences from "$lib/api/default_preferences";
|
||||
import StatusIcon from "$lib/components/StatusIcon.svelte";
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ export const load = async ({ params }) => {
|
|||
(e as APIError).code === ErrorCode.UserNotFound ||
|
||||
(e as APIError).code === ErrorCode.MemberNotFound
|
||||
) {
|
||||
error(404, e as App.Error);
|
||||
error(404, e as APIError);
|
||||
}
|
||||
|
||||
error(500, e as App.Error);
|
||||
error(500, e as APIError);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,15 +5,7 @@
|
|||
import type { LayoutData } from "./$types";
|
||||
import { addToast, delToast } from "$lib/toast";
|
||||
import { apiFetchClient, fastFetchClient } from "$lib/api/fetch";
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
Nav,
|
||||
NavItem,
|
||||
} from "@sveltestrap/sveltestrap";
|
||||
import { Button, ButtonGroup, Modal, ModalBody, ModalFooter, Nav, NavItem } from "@sveltestrap/sveltestrap";
|
||||
import { goto } from "$app/navigation";
|
||||
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
|
||||
import IconButton from "$lib/components/IconButton.svelte";
|
||||
|
|
|
@ -41,9 +41,8 @@ export const load = (async ({ params }) => {
|
|||
pronouns: pronouns.autocomplete,
|
||||
flags,
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
if ("code" in e) error(500, e as App.Error);
|
||||
} catch (e) {
|
||||
if ("code" in e) error(500, e as APIError);
|
||||
throw e;
|
||||
}
|
||||
}) satisfies LayoutLoad;
|
||||
|
|
|
@ -45,7 +45,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Button on:click={() => ($member.fields = [...$member.fields, { name: null, entries: [] }])}>
|
||||
<Button
|
||||
on:click={() => ($member.fields = [...$member.fields, { name: null, entries: [] }])}
|
||||
>
|
||||
<Icon name="plus" aria-hidden /> Add new field
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { PrideFlag, MeUser, PronounsJson } from "$lib/api/entities";
|
||||
import type { PrideFlag, APIError, MeUser, PronounsJson } from "$lib/api/entities";
|
||||
import { apiFetchClient } from "$lib/api/fetch";
|
||||
import { error, redirect } from "@sveltejs/kit";
|
||||
import { error, redirect, type Redirect } from "@sveltejs/kit";
|
||||
|
||||
import pronounsRaw from "$lib/pronouns.json";
|
||||
const pronouns = pronounsRaw as PronounsJson;
|
||||
|
@ -21,9 +21,8 @@ export const load = async ({ params }) => {
|
|||
pronouns: pronouns.autocomplete,
|
||||
flags,
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
if ("code" in e) error(500, e as App.Error);
|
||||
} catch (e) {
|
||||
if ("code" in e) error(500, e as APIError);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,14 +4,7 @@
|
|||
|
||||
import { PreferenceSize, type APIError, type MeUser } from "$lib/api/entities";
|
||||
import IconButton from "$lib/components/IconButton.svelte";
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
FormGroup,
|
||||
Icon,
|
||||
Input,
|
||||
InputGroup,
|
||||
} from "@sveltestrap/sveltestrap";
|
||||
import { Button, ButtonGroup, FormGroup, Icon, Input, InputGroup } from "@sveltestrap/sveltestrap";
|
||||
import { PUBLIC_SHORT_BASE } from "$env/static/public";
|
||||
import CustomPreference from "./CustomPreference.svelte";
|
||||
import { DateTime, FixedOffsetZone } from "luxon";
|
||||
|
|
|
@ -11,7 +11,7 @@ export const load = async ({ params }) => {
|
|||
redirect(303, `/@${resp.name}`);
|
||||
} catch (e) {
|
||||
if ((e as APIError).code === ErrorCode.UserNotFound) {
|
||||
error(404, e as App.Error);
|
||||
error(404, e as APIError);
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
|
|
@ -64,10 +64,8 @@
|
|||
) => Promise<void>;
|
||||
|
||||
let captchaToken = "";
|
||||
// svelte-hcaptcha doesn't have types, so we can't use anything except `any` here.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let captcha: any;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
||||
const captchaSuccess = (token: any) => {
|
||||
captchaToken = token.detail.token;
|
||||
};
|
||||
|
@ -90,8 +88,6 @@
|
|||
await fastFetch("/auth/force-delete", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
// We know for sure this value is non-null if this function is run at all
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
"X-Delete-Token": token!,
|
||||
},
|
||||
});
|
||||
|
@ -109,8 +105,6 @@
|
|||
await fastFetch("/auth/cancel-delete", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
// We know for sure this value is non-null if this function is run at all
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
"X-Delete-Token": token!,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
export let data: PageData;
|
||||
|
||||
let callbackPage: CallbackPage;
|
||||
let callbackPage: any;
|
||||
|
||||
const signupForm = async (username: string, invite: string, captchaToken: string) => {
|
||||
try {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
export let data: PageData;
|
||||
|
||||
let callbackPage: CallbackPage;
|
||||
let callbackPage: any;
|
||||
|
||||
const signupForm = async (username: string, invite: string, captchaToken: string) => {
|
||||
try {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
export let data: PageData;
|
||||
|
||||
let callbackPage: CallbackPage;
|
||||
let callbackPage: any;
|
||||
|
||||
const signupForm = async (username: string, invite: string, captchaToken: string) => {
|
||||
try {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
export let data: PageData;
|
||||
|
||||
let callbackPage: CallbackPage;
|
||||
let callbackPage: any;
|
||||
|
||||
const signupForm = async (username: string, invite: string, captchaToken: string) => {
|
||||
try {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
export let data: PageData;
|
||||
|
||||
let callbackPage: CallbackPage;
|
||||
let callbackPage: any;
|
||||
|
||||
const signupForm = async (username: string, invite: string, captchaToken: string) => {
|
||||
try {
|
||||
|
|
|
@ -23,7 +23,7 @@ export const load = async ({ params }) => {
|
|||
(e as APIError).code === ErrorCode.InvalidToken ||
|
||||
(e as APIError).code === ErrorCode.NotOwnMember
|
||||
) {
|
||||
error(403, e as App.Error);
|
||||
error(403, e as APIError);
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
|
|
@ -14,7 +14,7 @@ export const load = async () => {
|
|||
(e as APIError).code === ErrorCode.Forbidden ||
|
||||
(e as APIError).code === ErrorCode.InvalidToken
|
||||
) {
|
||||
error(403, e as App.Error);
|
||||
error(403, e as APIError);
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<script lang="ts">
|
||||
// Ignoring the TS error here, because this file imports fine, typescript just chokes on markdown files
|
||||
// eslint-disable-next-line
|
||||
//@ts-ignore
|
||||
import { html } from "./about.md";
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
// Ignoring the TS error here, because this file imports fine, typescript just chokes on markdown files
|
||||
// eslint-disable-next-line
|
||||
//@ts-ignore
|
||||
import { html } from "./changelog.md";
|
||||
import { CURRENT_CHANGELOG } from "$lib/store";
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<script lang="ts">
|
||||
// Ignoring the TS error here, because this file imports fine, typescript just chokes on markdown files
|
||||
// eslint-disable-next-line
|
||||
//@ts-ignore
|
||||
import { html } from "./privacy.md";
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<script lang="ts">
|
||||
// Ignoring the TS error here, because this file imports fine, typescript just chokes on markdown files
|
||||
// eslint-disable-next-line
|
||||
//@ts-ignore
|
||||
import { html } from "./terms.md";
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||
import type { PageData } from "./$types";
|
||||
import type { PageData } from "../../$types";
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
|
|
|
@ -3,14 +3,7 @@
|
|||
import { fastFetchClient } from "$lib/api/fetch";
|
||||
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
|
||||
import { addToast } from "$lib/toast";
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
FormGroup,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
} from "@sveltestrap/sveltestrap";
|
||||
import { Button, ButtonGroup, FormGroup, Modal, ModalBody, ModalFooter } from "@sveltestrap/sveltestrap";
|
||||
import type { PageData } from "./$types";
|
||||
import ReportCard from "./ReportCard.svelte";
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
Table,
|
||||
} from "@sveltestrap/sveltestrap";
|
||||
import type { PageData } from "./$types";
|
||||
import { onMount } from "svelte";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
export let data: PageData;
|
||||
|
|
|
@ -10,6 +10,6 @@ export const load = async () => {
|
|||
} catch (e) {
|
||||
if ((e as APIError).code === ErrorCode.NotFound) return { exportData: null };
|
||||
|
||||
error(500, e as App.Error);
|
||||
error(500, e as APIError);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { MAX_FLAGS, type APIError, type PrideFlag } from "$lib/api/entities";
|
||||
import {
|
||||
Button,
|
||||
Icon,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
} from "@sveltestrap/sveltestrap";
|
||||
import { Button, Icon, Input, Modal, ModalBody, ModalFooter, ModalHeader } from "@sveltestrap/sveltestrap";
|
||||
import type { PageData } from "./$types";
|
||||
import Flag from "./Flag.svelte";
|
||||
import prettyBytes from "pretty-bytes";
|
||||
|
|
|
@ -2,14 +2,7 @@
|
|||
import { flagURL, type APIError, type PrideFlag } from "$lib/api/entities";
|
||||
import { apiFetchClient } from "$lib/api/fetch";
|
||||
import { addToast } from "$lib/toast";
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
} from "@sveltestrap/sveltestrap";
|
||||
import { Button, Input, Modal, ModalBody, ModalFooter, ModalHeader } from "@sveltestrap/sveltestrap";
|
||||
|
||||
export let flag: PrideFlag;
|
||||
export let deleteFlag: (id: string) => Promise<void>;
|
||||
|
|
18
frontend/src/svelte-hcaptcha.d.ts
vendored
18
frontend/src/svelte-hcaptcha.d.ts
vendored
|
@ -1,18 +0,0 @@
|
|||
declare module "svelte-hcaptcha" {
|
||||
import type { SvelteComponent } from "svelte";
|
||||
|
||||
export interface HCaptchaProps {
|
||||
sitekey?: string;
|
||||
apihost?: string;
|
||||
hl?: string;
|
||||
reCaptchaCompat?: boolean;
|
||||
theme?: CaptchaTheme;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
declare class HCaptcha extends SvelteComponent {
|
||||
$$prop_def: HCaptchaProps;
|
||||
}
|
||||
|
||||
export default HCaptcha;
|
||||
}
|
|
@ -11,7 +11,7 @@ const config = {
|
|||
kit: {
|
||||
adapter: adapter(),
|
||||
version: {
|
||||
name: child_process.execSync("git describe --tags --long --always").toString().trim(),
|
||||
name: child_process.execSync("git describe --tags --long").toString().trim(),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -2,15 +2,12 @@ package cleandb
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
dbpkg "codeberg.org/pronounscc/pronouns.cc/backend/db"
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/log"
|
||||
"github.com/georgysavva/scany/v2/pgxscan"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/rs/xid"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -80,12 +77,7 @@ func run(c *cli.Context) error {
|
|||
fmt.Printf("error starting transaction: %v\n", err)
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
inactiveUsers, err := db.InactiveUsers(ctx, tx)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package seeddb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"codeberg.org/pronounscc/pronouns.cc/backend/db"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -84,12 +82,7 @@ func run(c *cli.Context) error {
|
|||
log.Println("error beginning transaction:", err)
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(ctx)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Println("error rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
for i, su := range seed.Users {
|
||||
u, err := pg.CreateUser(ctx, tx, su.Username)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package snowflakes
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
@ -40,12 +39,7 @@ func run(c *cli.Context) error {
|
|||
log.Error("creating transaction:", err)
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
err := tx.Rollback(c.Context)
|
||||
if err != nil && !errors.Is(err, pgx.ErrTxClosed) {
|
||||
log.Error("rolling back transaction:", err)
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback(c.Context)
|
||||
|
||||
var userIDs []xid.ID
|
||||
err = pgxscan.Select(c.Context, conn, &userIDs, "SELECT id FROM users WHERE snowflake_id IS NULL")
|
||||
|
|
Loading…
Reference in a new issue