···
// HandleBlock blocks a community
26
-
// POST /xrpc/social.coves.community.block
27
-
// Body: { "community": "did:plc:xxx" or "!gaming@coves.social" }
26
+
// POST /xrpc/social.coves.community.blockCommunity
28
+
// Request body: { "community": "did:plc:xxx" }
29
+
// Note: Per lexicon spec, only DIDs are accepted (not handles).
30
+
// The block record's "subject" field requires format: "did".
func (h *BlockHandler) HandleBlock(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
···
36
-
Community string `json:"community"` // DID or handle
39
+
Community string `json:"community"` // DID only (per lexicon)
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
···
49
-
// Validate format (DID or handle) with proper regex patterns
50
-
if strings.HasPrefix(req.Community, "did:") {
51
-
// Validate DID format: did:method:identifier
52
-
// atProto supports did:plc and did:web
53
-
didRegex := regexp.MustCompile(`^did:(plc|web):[a-zA-Z0-9._:%-]+$`)
54
-
if !didRegex.MatchString(req.Community) {
55
-
writeError(w, http.StatusBadRequest, "InvalidRequest", "invalid DID format")
58
-
} else if strings.HasPrefix(req.Community, "!") {
59
-
// Validate handle format: !name@domain.tld
60
-
if !strings.Contains(req.Community, "@") {
61
-
writeError(w, http.StatusBadRequest, "InvalidRequest", "handle must contain @domain")
52
+
// Validate DID format (per lexicon: format must be "did")
53
+
if !strings.HasPrefix(req.Community, "did:") {
writeError(w, http.StatusBadRequest, "InvalidRequest",
66
-
"community must be a DID (did:plc:...) or handle (!name@instance.com)")
55
+
"community must be a DID (did:plc:... or did:web:...)")
59
+
// Validate DID format with regex: did:method:identifier
60
+
didRegex := regexp.MustCompile(`^did:(plc|web):[a-zA-Z0-9._:%-]+$`)
61
+
if !didRegex.MatchString(req.Community) {
62
+
writeError(w, http.StatusBadRequest, "InvalidRequest", "invalid DID format")
···
// HandleUnblock unblocks a community
106
-
// POST /xrpc/social.coves.community.unblock
107
-
// Body: { "community": "did:plc:xxx" or "!gaming@coves.social" }
102
+
// POST /xrpc/social.coves.community.unblockCommunity
104
+
// Request body: { "community": "did:plc:xxx" }
105
+
// Note: Per lexicon spec, only DIDs are accepted (not handles).
func (h *BlockHandler) HandleUnblock(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
···
116
-
Community string `json:"community"`
114
+
Community string `json:"community"` // DID only (per lexicon)
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
···
129
-
// Validate format (DID or handle) with proper regex patterns
130
-
if strings.HasPrefix(req.Community, "did:") {
131
-
// Validate DID format: did:method:identifier
132
-
didRegex := regexp.MustCompile(`^did:(plc|web):[a-zA-Z0-9._:%-]+$`)
133
-
if !didRegex.MatchString(req.Community) {
134
-
writeError(w, http.StatusBadRequest, "InvalidRequest", "invalid DID format")
137
-
} else if strings.HasPrefix(req.Community, "!") {
138
-
// Validate handle format: !name@domain.tld
139
-
if !strings.Contains(req.Community, "@") {
140
-
writeError(w, http.StatusBadRequest, "InvalidRequest", "handle must contain @domain")
127
+
// Validate DID format (per lexicon: format must be "did")
128
+
if !strings.HasPrefix(req.Community, "did:") {
writeError(w, http.StatusBadRequest, "InvalidRequest",
145
-
"community must be a DID (did:plc:...) or handle (!name@instance.com)")
130
+
"community must be a DID (did:plc:... or did:web:...)")
134
+
// Validate DID format with regex: did:method:identifier
135
+
didRegex := regexp.MustCompile(`^did:(plc|web):[a-zA-Z0-9._:%-]+$`)
136
+
if !didRegex.MatchString(req.Community) {
137
+
writeError(w, http.StatusBadRequest, "InvalidRequest", "invalid DID format")