+4
Makefile
+4
Makefile
···
74
74
.env:
75
75
if [ ! -f ".env" ]; then cp example.dev.env .env; fi
76
76
77
+
.PHONY: run-postgres
78
+
run-postgres: .env ## Runs a local postgres instance
79
+
docker compose -f cmd/bigsky/docker-compose.yml up -d
80
+
77
81
.PHONY: run-dev-bgs
78
82
run-dev-bgs: .env ## Runs 'bigsky' BGS for local dev
79
83
GOLOG_LOG_LEVEL=info go run ./cmd/bigsky --admin-key localdev
+24
-1
bgs/bgs.go
+24
-1
bgs/bgs.go
···
264
264
e.HideBanner = true
265
265
266
266
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
267
-
AllowOrigins: []string{"http://localhost:*", "https://bgs.bsky-sandbox.dev"},
267
+
AllowOrigins: []string{"*"},
268
268
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept, echo.HeaderAuthorization},
269
269
}))
270
270
···
1052
1052
return nil, fmt.Errorf("refusing to create user on PDS at max repo limit")
1053
1053
}
1054
1054
1055
+
// Increment the repo count for the PDS
1056
+
res := s.db.Model(&models.PDS{}).Where("id = ? AND repo_count < repo_limit", peering.ID).Update("repo_count", gorm.Expr("repo_count + 1"))
1057
+
if res.Error != nil {
1058
+
return nil, fmt.Errorf("failed to increment repo count for pds: %w", res.Error)
1059
+
}
1060
+
1061
+
if res.RowsAffected == 0 {
1062
+
return nil, fmt.Errorf("refusing to create user on PDS at max repo limit")
1063
+
}
1064
+
1065
+
successfullyCreated := false
1066
+
1067
+
// Release the count if we fail to create the user
1068
+
defer func() {
1069
+
if !successfullyCreated {
1070
+
if err := s.db.Model(&models.PDS{}).Where("id = ?", peering.ID).Update("repo_count", gorm.Expr("repo_count - 1")).Error; err != nil {
1071
+
log.Errorf("failed to decrement repo count for pds: %s", err)
1072
+
}
1073
+
}
1074
+
}()
1075
+
1055
1076
ban, err := s.domainIsBanned(ctx, durl.Host)
1056
1077
if err != nil {
1057
1078
return nil, fmt.Errorf("failed to check pds ban status: %w", err)
···
1215
1236
if err := s.db.Create(subj).Error; err != nil {
1216
1237
return nil, err
1217
1238
}
1239
+
1240
+
successfullyCreated = true
1218
1241
1219
1242
return subj, nil
1220
1243
}
+2
cmd/bigsky/docker-compose.yml
+2
cmd/bigsky/docker-compose.yml
+3
-1
ts/bgs-dash/src/constants.ts
+3
-1
ts/bgs-dash/src/constants.ts