diff --git a/appview/ingester.go b/appview/ingester.go
--- a/appview/ingester.go
+++ b/appview/ingester.go
@@ -1621,10 +1621,9 @@ if err := comment.Validate(); err != nil {
return fmt.Errorf("failed to validate comment: %w", err)
}
- var mentions []syntax.DID
var references []syntax.ATURI
if comment.Body.Original != nil {
- mentions, references = i.MentionsResolver.Resolve(ctx, *comment.Body.Original)
+ _, references = i.MentionsResolver.Resolve(ctx, *comment.Body.Original)
}
tx, err := i.Db.Begin()
@@ -1633,17 +1632,13 @@ return fmt.Errorf("failed to start transaction: %w", err)
}
defer tx.Rollback()
- updated, err := db.PutComment(tx, comment, references)
+ _, err = db.PutComment(tx, comment, references)
if err != nil {
return fmt.Errorf("failed to create comment: %w", err)
}
if err := tx.Commit(); err != nil {
return err
- }
-
- if e.Commit.Operation == jmodels.CommitOperationCreate && updated {
- i.Notifier.NewComment(ctx, comment, mentions)
}
case jmodels.CommitOperationDelete:
diff --git a/appview/issues/issues.go b/appview/issues/issues.go
--- a/appview/issues/issues.go
+++ b/appview/issues/issues.go
@@ -101,7 +101,7 @@ }
entities := []syntax.ATURI{issue.AtUri()}
for _, c := range issue.Comments {
- entities = append(entities, c.AtUri())
+ entities = append(entities, c.FeedCommentAtUri())
}
reactions, err := db.ListReactionDisplayDataMap(rp.db, entities, 20)
if err != nil {
diff --git a/appview/models/comment.go b/appview/models/comment.go
--- a/appview/models/comment.go
+++ b/appview/models/comment.go
@@ -36,6 +36,11 @@ func (c Comment) AtUri() syntax.ATURI {
return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", c.Did, c.Collection, c.Rkey))
}
+// force-return the feed.comment NSID
+func (c Comment) FeedCommentAtUri() syntax.ATURI {
+ return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", c.Did, tangled.FeedCommentNSID, c.Rkey))
+}
+
func (c Comment) StrongRef() comatproto.RepoStrongRef {
return comatproto.RepoStrongRef{
Uri: c.AtUri().String(),
diff --git a/appview/pages/templates/fragments/comment/commentBody.html b/appview/pages/templates/fragments/comment/commentBody.html
--- a/appview/pages/templates/fragments/comment/commentBody.html
+++ b/appview/pages/templates/fragments/comment/commentBody.html
@@ -5,7 +5,7 @@
{{ template "topLevelComment"
(dict
"LoggedInUser" $root.LoggedInUser
- "Reactions" (index (asReactionMapMap $root.Reactions) $item.Self.AtUri)
- "UserReacted" (index (asReactionStatusMapMap $root.UserReacted) $item.Self.AtUri)
+ "Reactions" (index (asReactionMapMap $root.Reactions) $item.Self.FeedCommentAtUri)
+ "UserReacted" (index (asReactionStatusMapMap $root.UserReacted) $item.Self.FeedCommentAtUri)
"VouchRelationship" (index $root.VouchRelationships $item.Self.Did)
"Comment" $item.Self) }}
@@ -25,8 +25,8 @@
{{ template "replyComment"
(dict
"LoggedInUser" $root.LoggedInUser
- "Reactions" (index (asReactionMapMap $root.Reactions) $reply.AtUri)
- "UserReacted" (index (asReactionStatusMapMap $root.UserReacted) $reply.AtUri)
+ "Reactions" (index (asReactionMapMap $root.Reactions) $reply.FeedCommentAtUri)
+ "UserReacted" (index (asReactionStatusMapMap $root.UserReacted) $reply.FeedCommentAtUri)
"VouchRelationship" (index $root.VouchRelationships $reply.Did)
"Comment" $reply) }}
diff --git a/appview/pages/templates/repo/pulls/pull.html b/appview/pages/templates/repo/pulls/pull.html
--- a/appview/pages/templates/repo/pulls/pull.html
+++ b/appview/pages/templates/repo/pulls/pull.html
@@ -598,8 +598,8 @@ {{ range $item.Comments }}
{{/* template "submissionComment" . */}}
{{ template "comment"
(dict "LoggedInUser" $root.LoggedInUser
- "Reactions" (index (asReactionMapMap $root.Reactions) .AtUri)
- "UserReacted" (index (asReactionStatusMapMap $root.UserReacted) .AtUri)
+ "Reactions" (index (asReactionMapMap $root.Reactions) .FeedCommentAtUri)
+ "UserReacted" (index (asReactionStatusMapMap $root.UserReacted) .FeedCommentAtUri)
"VouchRelationship" (index $root.VouchRelationships .Did)
"Comment" .) }}
{{ end }}
diff --git a/appview/pulls/single.go b/appview/pulls/single.go
--- a/appview/pulls/single.go
+++ b/appview/pulls/single.go
@@ -163,7 +163,7 @@
entities := []syntax.ATURI{pull.AtUri()}
for _, s := range pull.Submissions {
for _, c := range s.Comments {
- entities = append(entities, c.AtUri())
+ entities = append(entities, c.FeedCommentAtUri())
}
}
reactions, err := db.ListReactionDisplayDataMap(s.db, entities, 20)
diff --git a/appview/state/comment.go b/appview/state/comment.go
--- a/appview/state/comment.go
+++ b/appview/state/comment.go
@@ -34,13 +34,13 @@ http.Error(w, "Failed to fetch comment", http.StatusInternalServerError)
return
}
- reactions, err := db.GetReactionMap(s.db, 20, comment.AtUri())
+ reactions, err := db.GetReactionMap(s.db, 20, comment.FeedCommentAtUri())
if err != nil {
l.Error("failed to get reactions", "err", err)
}
var userReactions map[models.ReactionKind]bool
if user != nil {
- userReactions, err = db.GetReactionStatusMap(s.db, syntax.DID(user.Did), comment.AtUri())
+ userReactions, err = db.GetReactionStatusMap(s.db, syntax.DID(user.Did), comment.FeedCommentAtUri())
if err != nil {
l.Error("failed to get user reactions", "err", err)
}
@@ -102,7 +102,7 @@ }
// TODO(boltless): normalize markdown body
normalizedBody := body
- _, references := s.mentionsResolver.Resolve(ctx, body)
+ mentions, references := s.mentionsResolver.Resolve(ctx, body)
markdownBody := tangled.MarkupMarkdown{
Text: normalizedBody,
@@ -293,6 +293,8 @@ s.pages.Notice(w, noticeId, "Failed to create comment, try again later.")
return
}
+ s.notifier.NewComment(ctx, &comment, mentions)
+
// TODO: return comment or reply-comment fragment
// onattach, htmx-callback to focus on comment.
s.pages.HxRefresh(w)
@@ -390,11 +392,11 @@ s.pages.Notice(w, noticeId, "Failed to update comment, try again later.")
return
}
- reactions, err := db.GetReactionMap(s.db, 20, comment.AtUri())
+ reactions, err := db.GetReactionMap(s.db, 20, comment.FeedCommentAtUri())
if err != nil {
l.Error("failed to get reactions", "err", err)
}
- userReactions, err := db.GetReactionStatusMap(s.db, syntax.DID(user.Did), comment.AtUri())
+ userReactions, err := db.GetReactionStatusMap(s.db, syntax.DID(user.Did), comment.FeedCommentAtUri())
if err != nil {
l.Error("failed to get user reactions", "err", err)
}
diff --git a/appview/state/reaction.go b/appview/state/reaction.go
--- a/appview/state/reaction.go
+++ b/appview/state/reaction.go
@@ -1,6 +1,7 @@
package state
import (
+ "fmt"
"net/http"
"time"
@@ -29,6 +30,12 @@ subjectUri, err := syntax.ParseATURI(subject)
if err != nil {
l.Warn("invalid form", "subject", subject, "err", err)
return
+ }
+
+ // override collection NSID to new one
+ switch subjectUri.Collection() {
+ case tangled.RepoIssueCommentNSID, tangled.RepoPullCommentNSID:
+ subjectUri = syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", subjectUri.Authority(), tangled.FeedCommentNSID, subjectUri.RecordKey()))
}
reactionKind, ok := models.ParseReactionKind(r.URL.Query().Get("kind"))