diff --git a/appview/ingester.go b/appview/ingester.go
index 63b2b1ae..5cee6fe0 100644
--- a/appview/ingester.go
+++ b/appview/ingester.go
@@ -1621,10 +1621,9 @@ func (i *Ingester) ingestComment(e *jmodels.Event) error {
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,7 +1632,7 @@ func (i *Ingester) ingestComment(e *jmodels.Event) error {
}
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)
}
@@ -1642,10 +1641,6 @@ func (i *Ingester) ingestComment(e *jmodels.Event) error {
return err
}
- if e.Commit.Operation == jmodels.CommitOperationCreate && updated {
- i.Notifier.NewComment(ctx, comment, mentions)
- }
-
case jmodels.CommitOperationDelete:
if err := db.DeleteComments(
i.Db,
diff --git a/appview/issues/issues.go b/appview/issues/issues.go
index 5480b561..2b114f5a 100644
--- a/appview/issues/issues.go
+++ b/appview/issues/issues.go
@@ -101,7 +101,7 @@ func (rp *Issues) RepoSingleIssue(w http.ResponseWriter, r *http.Request) {
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
index 39188652..b01d7905 100644
--- 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
index c5f820d7..2a8d35e8 100644
--- a/appview/pages/templates/fragments/comment/commentBody.html
+++ b/appview/pages/templates/fragments/comment/commentBody.html
@@ -5,7 +5,7 @@
{{ template "repo/fragments/reactions"
(dict "Reactions" .Reactions
"UserReacted" .UserReacted
- "ThreadAt" .Comment.AtUri) }}
+ "ThreadAt" .Comment.FeedCommentAtUri) }}
{{ else }}
[deleted by author]
{{ end }}
diff --git a/appview/pages/templates/fragments/comment/commentList.html b/appview/pages/templates/fragments/comment/commentList.html
index 1d4cd3e8..ca1f5cba 100644
--- a/appview/pages/templates/fragments/comment/commentList.html
+++ b/appview/pages/templates/fragments/comment/commentList.html
@@ -14,8 +14,8 @@
{{ 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
index 058d7887..76056153 100644
--- a/appview/pages/templates/repo/pulls/pull.html
+++ b/appview/pages/templates/repo/pulls/pull.html
@@ -598,8 +598,8 @@
{{/* 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
index 871e0bad..f97eecf9 100644
--- a/appview/pulls/single.go
+++ b/appview/pulls/single.go
@@ -163,7 +163,7 @@ func (s *Pulls) repoPullHelper(w http.ResponseWriter, r *http.Request, interdiff
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
index 894130a3..4af31d6c 100644
--- a/appview/state/comment.go
+++ b/appview/state/comment.go
@@ -34,13 +34,13 @@ func (s *State) CommentBodyFragment(w http.ResponseWriter, r *http.Request) {
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 @@ func (s *State) NewComment(w http.ResponseWriter, r *http.Request) {
// 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 @@ func (s *State) NewComment(w http.ResponseWriter, r *http.Request) {
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 @@ func (s *State) EditComment(w http.ResponseWriter, r *http.Request) {
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
index 3257ed70..b5c4cfce 100644
--- a/appview/state/reaction.go
+++ b/appview/state/reaction.go
@@ -1,6 +1,7 @@
package state
import (
+ "fmt"
"net/http"
"time"
@@ -31,6 +32,12 @@ func (s *State) React(w http.ResponseWriter, r *http.Request) {
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"))
if !ok {
l.Warn("invalid reaction kind", "kind", r.URL.Query().Get("kind"))