(READ ONLY) Margin is an open annotation layer for the internet. Powered by the AT Protocol. margin.at
extension web atproto comments
98
fork

Configure Feed

Select the types of activity you want to include in your feed.

gofmt

scanash00 92ad1ff3 856910c9

+48 -56
+12 -16
backend/internal/api/moderation.go
··· 110 110 json.NewEncoder(w).Encode(map[string]interface{}{"items": items}) 111 111 } 112 112 113 - 114 113 func (m *ModerationHandler) MuteUser(w http.ResponseWriter, r *http.Request) { 115 114 session, err := m.refresher.GetSessionWithAutoRefresh(r) 116 115 if err != nil { ··· 225 224 }) 226 225 } 227 226 228 - 229 227 func (m *ModerationHandler) CreateReport(w http.ResponseWriter, r *http.Request) { 230 228 session, err := m.refresher.GetSessionWithAutoRefresh(r) 231 229 if err != nil { ··· 250 248 } 251 249 252 250 validReasons := map[string]bool{ 253 - "spam": true, 254 - "violation": true, 255 - "misleading": true, 256 - "sexual": true, 257 - "rude": true, 258 - "other": true, 251 + "spam": true, 252 + "violation": true, 253 + "misleading": true, 254 + "sexual": true, 255 + "rude": true, 256 + "other": true, 259 257 } 260 258 261 259 if !validReasons[req.ReasonType] { ··· 274 272 json.NewEncoder(w).Encode(map[string]interface{}{"id": id, "status": "ok"}) 275 273 } 276 274 277 - 278 275 func (m *ModerationHandler) AdminGetReports(w http.ResponseWriter, r *http.Request) { 279 276 session, err := m.refresher.GetSessionWithAutoRefresh(r) 280 277 if err != nil { ··· 477 474 m.db.Exec("DELETE FROM replies WHERE uri = $1", uri) 478 475 } 479 476 480 - 481 477 func (m *ModerationHandler) AdminCreateLabel(w http.ResponseWriter, r *http.Request) { 482 478 session, err := m.refresher.GetSessionWithAutoRefresh(r) 483 479 if err != nil { ··· 607 603 profiles := fetchProfilesForDIDs(m.db, dids) 608 604 609 605 type HydratedLabel struct { 610 - ID int `json:"id"` 611 - Src string `json:"src"` 612 - URI string `json:"uri"` 613 - Val string `json:"val"` 614 - CreatedBy Author `json:"createdBy"` 615 - CreatedAt string `json:"createdAt"` 606 + ID int `json:"id"` 607 + Src string `json:"src"` 608 + URI string `json:"uri"` 609 + Val string `json:"val"` 610 + CreatedBy Author `json:"createdBy"` 611 + CreatedAt string `json:"createdAt"` 616 612 Subject *Author `json:"subject,omitempty"` 617 613 } 618 614
+2 -2
backend/internal/api/preferences.go
··· 23 23 24 24 type PreferencesResponse struct { 25 25 ExternalLinkSkippedHostnames []string `json:"externalLinkSkippedHostnames"` 26 - SubscribedLabelers []LabelerSubscription `json:"subscribedLabelers"` 27 - LabelPreferences []LabelPreference `json:"labelPreferences"` 26 + SubscribedLabelers []LabelerSubscription `json:"subscribedLabelers"` 27 + LabelPreferences []LabelPreference `json:"labelPreferences"` 28 28 } 29 29 30 30 func (h *Handler) GetPreferences(w http.ResponseWriter, r *http.Request) {
+16 -16
backend/internal/db/db.go
··· 171 171 } 172 172 173 173 type ModerationReport struct { 174 - ID int `json:"id"` 175 - ReporterDID string `json:"reporterDid"` 176 - SubjectDID string `json:"subjectDid"` 177 - SubjectURI *string `json:"subjectUri,omitempty"` 178 - ReasonType string `json:"reasonType"` 179 - ReasonText *string `json:"reasonText,omitempty"` 180 - Status string `json:"status"` 181 - CreatedAt time.Time `json:"createdAt"` 182 - ResolvedAt *time.Time `json:"resolvedAt,omitempty"` 183 - ResolvedBy *string `json:"resolvedBy,omitempty"` 174 + ID int `json:"id"` 175 + ReporterDID string `json:"reporterDid"` 176 + SubjectDID string `json:"subjectDid"` 177 + SubjectURI *string `json:"subjectUri,omitempty"` 178 + ReasonType string `json:"reasonType"` 179 + ReasonText *string `json:"reasonText,omitempty"` 180 + Status string `json:"status"` 181 + CreatedAt time.Time `json:"createdAt"` 182 + ResolvedAt *time.Time `json:"resolvedAt,omitempty"` 183 + ResolvedBy *string `json:"resolvedBy,omitempty"` 184 184 } 185 185 186 186 type ModerationAction struct { 187 - ID int `json:"id"` 188 - ReportID int `json:"reportId"` 189 - ActorDID string `json:"actorDid"` 190 - Action string `json:"action"` 191 - Comment *string `json:"comment,omitempty"` 192 - CreatedAt time.Time `json:"createdAt"` 187 + ID int `json:"id"` 188 + ReportID int `json:"reportId"` 189 + ActorDID string `json:"actorDid"` 190 + Action string `json:"action"` 191 + Comment *string `json:"comment,omitempty"` 192 + CreatedAt time.Time `json:"createdAt"` 193 193 } 194 194 195 195 type ContentLabel struct {
-4
backend/internal/db/queries_moderation.go
··· 2 2 3 3 import "time" 4 4 5 - 6 5 func (db *DB) CreateBlock(actorDID, subjectDID string) error { 7 6 query := `INSERT INTO blocks (actor_did, subject_did, created_at) VALUES (?, ?, ?) 8 7 ON CONFLICT(actor_did, subject_did) DO NOTHING` ··· 80 79 } 81 80 return dids, nil 82 81 } 83 - 84 82 85 83 func (db *DB) CreateMute(actorDID, subjectDID string) error { 86 84 query := `INSERT INTO mutes (actor_did, subject_did, created_at) VALUES (?, ?, ?) ··· 188 186 return 189 187 } 190 188 191 - 192 189 func (db *DB) CreateReport(reporterDID, subjectDID string, subjectURI *string, reasonType string, reasonText *string) (int, error) { 193 190 query := `INSERT INTO moderation_reports (reporter_did, subject_did, subject_uri, reason_type, reason_text, status, created_at) 194 191 VALUES (?, ?, ?, ?, ?, 'pending', ?)` ··· 283 280 err := db.QueryRow(db.Rebind(query), args...).Scan(&count) 284 281 return count, err 285 282 } 286 - 287 283 288 284 func (db *DB) CreateContentLabel(src, uri, val, createdBy string) error { 289 285 query := `INSERT INTO content_labels (src, uri, val, neg, created_by, created_at) VALUES (?, ?, ?, 0, ?, ?)`
+7 -7
backend/internal/sync/service.go
··· 189 189 } else { 190 190 err = e 191 191 } 192 - case xrpc.CollectionAPIKey: 193 - localURIs, err = s.db.GetAPIKeyURIs(did) 194 - localURIs = filterURIsByCollection(localURIs, xrpc.CollectionAPIKey) 195 - case xrpc.CollectionPreferences: 196 - localURIs, err = s.db.GetPreferenceURIs(did) 197 - localURIs = filterURIsByCollection(localURIs, xrpc.CollectionPreferences) 198 - case xrpc.CollectionSembleCollectionLink: 192 + case xrpc.CollectionAPIKey: 193 + localURIs, err = s.db.GetAPIKeyURIs(did) 194 + localURIs = filterURIsByCollection(localURIs, xrpc.CollectionAPIKey) 195 + case xrpc.CollectionPreferences: 196 + localURIs, err = s.db.GetPreferenceURIs(did) 197 + localURIs = filterURIsByCollection(localURIs, xrpc.CollectionPreferences) 198 + case xrpc.CollectionSembleCollectionLink: 199 199 items, e := s.db.GetCollectionItemsByAuthor(did) 200 200 if e == nil { 201 201 for _, item := range items {
+11 -11
backend/internal/xrpc/records.go
··· 332 332 } 333 333 334 334 type BookmarkRecord struct { 335 - Type string `json:"$type"` 336 - Source string `json:"source"` 337 - SourceHash string `json:"sourceHash"` 338 - Title string `json:"title,omitempty"` 339 - Description string `json:"description,omitempty"` 340 - Tags []string `json:"tags,omitempty"` 341 - Generator *Generator `json:"generator,omitempty"` 342 - Rights string `json:"rights,omitempty"` 335 + Type string `json:"$type"` 336 + Source string `json:"source"` 337 + SourceHash string `json:"sourceHash"` 338 + Title string `json:"title,omitempty"` 339 + Description string `json:"description,omitempty"` 340 + Tags []string `json:"tags,omitempty"` 341 + Generator *Generator `json:"generator,omitempty"` 342 + Rights string `json:"rights,omitempty"` 343 343 Labels *SelfLabels `json:"labels,omitempty"` 344 - CreatedAt string `json:"createdAt"` 344 + CreatedAt string `json:"createdAt"` 345 345 } 346 346 347 347 func (r *BookmarkRecord) Validate() error { ··· 474 474 type PreferencesRecord struct { 475 475 Type string `json:"$type"` 476 476 ExternalLinkSkippedHostnames []string `json:"externalLinkSkippedHostnames,omitempty"` 477 - SubscribedLabelers []LabelerSubscription `json:"subscribedLabelers,omitempty"` 478 - LabelPreferences []LabelPreference `json:"labelPreferences,omitempty"` 477 + SubscribedLabelers []LabelerSubscription `json:"subscribedLabelers,omitempty"` 478 + LabelPreferences []LabelPreference `json:"labelPreferences,omitempty"` 479 479 CreatedAt string `json:"createdAt"` 480 480 } 481 481