diff --git a/.env.example b/.env.example
index ad1d1e6..b6566ff 100644
--- a/.env.example
+++ b/.env.example
@@ -15,7 +15,7 @@ BASE_URL=http://localhost:5173
# S3/MinIO configuration, required for avatars, pride flags, and data exports
# Note: MINIO_ENDPOINT must be set and look like a minio endpoint, but doesn't
-# have to actually point to anything real
+# have to actually point to one you have access to
MINIO_ENDPOINT=example.com
MINIO_BUCKET=
MINIO_ACCESS_KEY_ID=
@@ -40,5 +40,5 @@ TUMBLR_CLIENT_ID=
TUMBLR_CLIENT_SECRET=
# Discord bot config - provide the app's public key in addition to client ID/
-# secret above to let the bot respond to command interactions over HTTP
+# secret from above to let the bot to respond to command interactions over HTTP
DISCORD_PUBLIC_KEY=
diff --git a/backend/db/db.go b/backend/db/db.go
index 13e12f2..5f7af5a 100644
--- a/backend/db/db.go
+++ b/backend/db/db.go
@@ -6,7 +6,6 @@ import (
"fmt"
"net/url"
"os"
- "sync"
"codeberg.org/pronounscc/pronouns.cc/backend/log"
"emperror.dev/errors"
@@ -42,10 +41,6 @@ type DB struct {
baseURL *url.URL
TotalRequests prometheus.Counter
-
- activeUsersDay, activeUsersWeek, activeUsersMonth int64
- usersTotal, membersTotal int64
- countMu sync.RWMutex
}
func New() (*DB, error) {
diff --git a/backend/db/fediverse.go b/backend/db/fediverse.go
index eeadd79..d319cad 100644
--- a/backend/db/fediverse.go
+++ b/backend/db/fediverse.go
@@ -48,7 +48,7 @@ func (f FediverseApp) ClientConfig() *oauth2.Config {
}
func (f FediverseApp) MastodonCompatible() bool {
- return f.InstanceType == "mastodon" || f.InstanceType == "pleroma" || f.InstanceType == "akkoma" || f.InstanceType == "pixelfed" || f.InstanceType == "gotosocial"
+ return f.InstanceType == "mastodon" || f.InstanceType == "pleroma" || f.InstanceType == "akkoma" || f.InstanceType == "pixelfed"
}
func (f FediverseApp) Misskey() bool {
diff --git a/backend/db/metrics.go b/backend/db/metrics.go
index 96661dd..c2a4cf9 100644
--- a/backend/db/metrics.go
+++ b/backend/db/metrics.go
@@ -21,11 +21,6 @@ func (db *DB) initMetrics() (err error) {
if err != nil {
log.Errorf("getting user count for metrics: %v", err)
}
-
- db.countMu.Lock()
- db.usersTotal = count
- db.countMu.Unlock()
-
return float64(count)
}))
if err != nil {
@@ -40,11 +35,6 @@ func (db *DB) initMetrics() (err error) {
if err != nil {
log.Errorf("getting member count for metrics: %v", err)
}
-
- db.countMu.Lock()
- db.membersTotal = count
- db.countMu.Unlock()
-
return float64(count)
}))
if err != nil {
@@ -59,11 +49,6 @@ func (db *DB) initMetrics() (err error) {
if err != nil {
log.Errorf("getting active user count for metrics: %v", err)
}
-
- db.countMu.Lock()
- db.activeUsersMonth = count
- db.countMu.Unlock()
-
return float64(count)
}))
if err != nil {
@@ -78,11 +63,6 @@ func (db *DB) initMetrics() (err error) {
if err != nil {
log.Errorf("getting active user count for metrics: %v", err)
}
-
- db.countMu.Lock()
- db.activeUsersWeek = count
- db.countMu.Unlock()
-
return float64(count)
}))
if err != nil {
@@ -97,11 +77,6 @@ func (db *DB) initMetrics() (err error) {
if err != nil {
log.Errorf("getting active user count for metrics: %v", err)
}
-
- db.countMu.Lock()
- db.activeUsersDay = count
- db.countMu.Unlock()
-
return float64(count)
}))
if err != nil {
@@ -132,22 +107,6 @@ func (db *DB) initMetrics() (err error) {
return nil
}
-func (db *DB) Counts(ctx context.Context) (numUsers, numMembers, usersDay, usersWeek, usersMonth int64) {
- db.countMu.Lock()
- if db.usersTotal != 0 {
- defer db.countMu.Unlock()
- return db.usersTotal, db.membersTotal, db.activeUsersDay, db.activeUsersWeek, db.activeUsersMonth
- }
- db.countMu.Unlock()
-
- numUsers, _ = db.TotalUserCount(ctx)
- numMembers, _ = db.TotalMemberCount(ctx)
- usersDay, _ = db.ActiveUsers(ctx, ActiveDay)
- usersWeek, _ = db.ActiveUsers(ctx, ActiveWeek)
- usersMonth, _ = db.ActiveUsers(ctx, ActiveMonth)
- return numUsers, numMembers, usersDay, usersWeek, usersMonth
-}
-
func (db *DB) TotalUserCount(ctx context.Context) (numUsers int64, err error) {
err = db.QueryRow(ctx, "SELECT COUNT(*) FROM users WHERE deleted_at IS NULL").Scan(&numUsers)
if err != nil {
diff --git a/backend/routes/auth/fediverse.go b/backend/routes/auth/fediverse.go
index b3f2f62..0f0511c 100644
--- a/backend/routes/auth/fediverse.go
+++ b/backend/routes/auth/fediverse.go
@@ -67,7 +67,7 @@ func (s *Server) noAppFediverseURL(ctx context.Context, w http.ResponseWriter, r
switch softwareName {
case "misskey", "foundkey", "calckey":
return s.noAppMisskeyURL(ctx, w, r, softwareName, instance)
- case "mastodon", "pleroma", "akkoma", "pixelfed", "gotosocial":
+ case "mastodon", "pleroma", "akkoma", "pixelfed":
case "glitchcafe":
// plural.cafe (potentially other instances too?) runs Mastodon but changes the software name
// changing it back to mastodon here for consistency
diff --git a/backend/routes/meta/meta.go b/backend/routes/meta/meta.go
index ebae428..da59f8d 100644
--- a/backend/routes/meta/meta.go
+++ b/backend/routes/meta/meta.go
@@ -4,7 +4,9 @@ import (
"net/http"
"os"
+ "codeberg.org/pronounscc/pronouns.cc/backend/db"
"codeberg.org/pronounscc/pronouns.cc/backend/server"
+ "emperror.dev/errors"
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
)
@@ -37,7 +39,30 @@ type MetaUsers struct {
func (s *Server) meta(w http.ResponseWriter, r *http.Request) error {
ctx := r.Context()
- numUsers, numMembers, activeDay, activeWeek, activeMonth := s.DB.Counts(ctx)
+ numUsers, err := s.DB.TotalUserCount(ctx)
+ if err != nil {
+ return errors.Wrap(err, "querying user count")
+ }
+
+ activeMonth, err := s.DB.ActiveUsers(ctx, db.ActiveMonth)
+ if err != nil {
+ return errors.Wrap(err, "querying user count")
+ }
+
+ activeWeek, err := s.DB.ActiveUsers(ctx, db.ActiveWeek)
+ if err != nil {
+ return errors.Wrap(err, "querying user count")
+ }
+
+ activeDay, err := s.DB.ActiveUsers(ctx, db.ActiveDay)
+ if err != nil {
+ return errors.Wrap(err, "querying user count")
+ }
+
+ numMembers, err := s.DB.TotalMemberCount(ctx)
+ if err != nil {
+ return errors.Wrap(err, "querying user count")
+ }
render.JSON(w, r, MetaResponse{
GitRepository: server.Repository,
diff --git a/backend/server/server.go b/backend/server/server.go
index 399ead0..7da468a 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -14,7 +14,6 @@ import (
"github.com/go-chi/cors"
"github.com/go-chi/httprate"
"github.com/go-chi/render"
- chiprometheus "github.com/toshi0607/chi-prometheus"
)
// Revision is the git commit, filled at build time
@@ -60,12 +59,6 @@ func New() (*Server, error) {
MaxAge: 300,
}))
- // enable request latency tracking
- os.Setenv(chiprometheus.EnvChiPrometheusLatencyBuckets, "10,25,50,100,300,500,1000,5000")
- prom := chiprometheus.New("pronouns.cc")
- s.Router.Use(prom.Handler)
- prom.MustRegisterDefault()
-
// enable authentication for all routes (but don't require it)
s.Router.Use(s.maybeAuth)
diff --git a/docs/production.md b/docs/production.md
index 9afe530..86f06ab 100644
--- a/docs/production.md
+++ b/docs/production.md
@@ -22,7 +22,7 @@ one in the repository root (for the backend) and one in the frontend directory.
### Backend keys
-- `HMAC_KEY`: the key used to sign tokens. This should be a base64 string, you can generate one with `go run -v . generate key` (or `./pronouns generate key` after building).
+- `HMAC_KEY`: the key used to sign tokens. This should be a base64 string, you can generate one with `scripts/genkey`.
- `DATABASE_URL`: the URL for the PostgreSQL database.
- `REDIS`: the URL for the Redis database.
- `PORT` (int): the port the backend will listen on.
diff --git a/frontend/src/routes/@[username]/ReportButton.svelte b/frontend/src/routes/@[username]/ReportButton.svelte
index 79dbc82..4f55f9d 100644
--- a/frontend/src/routes/@[username]/ReportButton.svelte
+++ b/frontend/src/routes/@[username]/ReportButton.svelte
@@ -45,9 +45,6 @@
terms of service.
-
- Note that we cannot take action on any reports that cannot be proven with just
- the reported profile and any external pages linked on it.