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

Configure Feed

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

some other fixes

+28 -4
+16 -3
backend/internal/api/apikey.go
··· 16 16 "github.com/go-chi/chi/v5" 17 17 18 18 "margin.at/internal/db" 19 + "margin.at/internal/domain" 19 20 "margin.at/internal/logger" 20 21 "margin.at/internal/xrpc" 21 22 ) ··· 221 222 h.db.UpdateAPIKeyLastUsed(apiKey.ID) 222 223 223 224 capturedTags := append([]string(nil), req.Tags...) 224 - go func(did, url string) { 225 + capturedURLHash := db.HashURL(req.URL) 226 + go func(did, url, urlHash string) { 225 227 prefs, dbErr := h.db.GetPreferences(did) 226 228 communityEnabled := dbErr == nil && prefs != nil && (prefs.EnableCommunityBookmarks == nil || *prefs.EnableCommunityBookmarks) 227 229 if !communityEnabled { ··· 242 244 } 243 245 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 244 246 defer cancel() 245 - _, _ = client.CreateRecord(ctx, did, xrpc.CollectionCommunityBookmark, communityRecord) 246 - }(apiKey.OwnerDID, req.URL) 247 + communityResult, communityErr := client.CreateRecord(ctx, did, xrpc.CollectionCommunityBookmark, communityRecord) 248 + if communityErr == nil && communityResult != nil { 249 + _ = h.db.CreateNote(&domain.Note{ 250 + URI: communityResult.URI, 251 + AuthorDID: did, 252 + Motivation: "bookmarking", 253 + TargetSource: url, 254 + TargetHash: urlHash, 255 + CreatedAt: time.Now(), 256 + IndexedAt: time.Now(), 257 + }) 258 + } 259 + }(apiKey.OwnerDID, req.URL, capturedURLHash) 247 260 248 261 var titlePtr, bodyValuePtr, tagsJSONPtr *string 249 262 if req.Title != "" {
+12 -1
backend/internal/api/notes.go
··· 1035 1035 if len(capturedTags) > 0 { 1036 1036 communityRecord["tags"] = capturedTags 1037 1037 } 1038 - _, _ = client.CreateRecord(ctx, capturedSession.DID, xrpc.CollectionCommunityBookmark, communityRecord) 1038 + communityResult, communityErr := client.CreateRecord(ctx, capturedSession.DID, xrpc.CollectionCommunityBookmark, communityRecord) 1039 + if communityErr == nil && communityResult != nil { 1040 + _ = s.db.CreateNote(&domain.Note{ 1041 + URI: communityResult.URI, 1042 + AuthorDID: capturedSession.DID, 1043 + Motivation: "bookmarking", 1044 + TargetSource: capturedURL, 1045 + TargetHash: capturedURLHash, 1046 + CreatedAt: time.Now(), 1047 + IndexedAt: time.Now(), 1048 + }) 1049 + } 1039 1050 }() 1040 1051 1041 1052 var titlePtr *string