appview/notify: use correct actor on issue/pr state change events #740

merged
opened by boltless.me targeting master from feat/mentions
Changed files
+24 -23
appview
+2 -2
appview/indexer/notifier.go
···
}
}
-
func (ix *Indexer) NewIssueState(ctx context.Context, issue *models.Issue) {
+
func (ix *Indexer) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
l.Debug("updating an issue")
err := ix.Issues.Index(ctx, *issue)
···
}
}
-
func (ix *Indexer) NewPullState(ctx context.Context, pull *models.Pull) {
+
func (ix *Indexer) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
l := log.FromContext(ctx).With("notifier", "indexer", "pull", pull)
l.Debug("updating a pr")
err := ix.Pulls.Index(ctx, pull)
+2 -2
appview/issues/issues.go
···
issue.Open = false
// notify about the issue closure
-
rp.notifier.NewIssueState(r.Context(), issue)
+
rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue)
rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId))
return
···
issue.Open = true
// notify about the issue reopen
-
rp.notifier.NewIssueState(r.Context(), issue)
+
rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue)
rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId))
return
+4 -6
appview/notify/db/db.go
···
// no-op
}
-
func (n *databaseNotifier) NewIssueState(ctx context.Context, issue *models.Issue) {
+
func (n *databaseNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
// build up the recipients list:
// - repo owner
// - repo collaborators
···
recipients = append(recipients, syntax.DID(p))
}
-
actorDid := syntax.DID(issue.Repo.Did)
entityType := "pull"
entityId := issue.AtUri().String()
repoId := &issue.Repo.Id
···
}
n.notifyEvent(
-
actorDid,
+
actor,
recipients,
eventType,
entityType,
···
)
}
-
func (n *databaseNotifier) NewPullState(ctx context.Context, pull *models.Pull) {
+
func (n *databaseNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
// Get repo details
repo, err := db.GetRepo(n.db, db.FilterEq("at_uri", string(pull.RepoAt)))
if err != nil {
···
recipients = append(recipients, syntax.DID(p))
}
-
actorDid := syntax.DID(repo.Did)
entityType := "pull"
entityId := pull.PullAt().String()
repoId := &repo.Id
···
pullId := &p
n.notifyEvent(
-
actorDid,
+
actor,
recipients,
eventType,
entityType,
+4 -4
appview/notify/merged_notifier.go
···
m.fanout("NewIssueComment", ctx, comment, mentions)
}
-
func (m *mergedNotifier) NewIssueState(ctx context.Context, issue *models.Issue) {
-
m.fanout("NewIssueState", ctx, issue)
+
func (m *mergedNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
+
m.fanout("NewIssueState", ctx, actor, issue)
}
func (m *mergedNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) {
···
m.fanout("NewPullComment", ctx, comment, mentions)
}
-
func (m *mergedNotifier) NewPullState(ctx context.Context, pull *models.Pull) {
-
m.fanout("NewPullState", ctx, pull)
+
func (m *mergedNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
+
m.fanout("NewPullState", ctx, actor, pull)
}
func (m *mergedNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {
+4 -4
appview/notify/notifier.go
···
NewIssue(ctx context.Context, issue *models.Issue, mentions []syntax.DID)
NewIssueComment(ctx context.Context, comment *models.IssueComment, mentions []syntax.DID)
-
NewIssueState(ctx context.Context, issue *models.Issue)
+
NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue)
DeleteIssue(ctx context.Context, issue *models.Issue)
NewFollow(ctx context.Context, follow *models.Follow)
···
NewPull(ctx context.Context, pull *models.Pull)
NewPullComment(ctx context.Context, comment *models.PullComment, mentions []syntax.DID)
-
NewPullState(ctx context.Context, pull *models.Pull)
+
NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull)
UpdateProfile(ctx context.Context, profile *models.Profile)
···
func (m *BaseNotifier) NewIssue(ctx context.Context, issue *models.Issue, mentions []syntax.DID) {}
func (m *BaseNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment, mentions []syntax.DID) {}
-
func (m *BaseNotifier) NewIssueState(ctx context.Context, issue *models.Issue) {}
+
func (m *BaseNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {}
func (m *BaseNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) {}
func (m *BaseNotifier) NewFollow(ctx context.Context, follow *models.Follow) {}
···
func (m *BaseNotifier) NewPull(ctx context.Context, pull *models.Pull) {}
func (m *BaseNotifier) NewPullComment(ctx context.Context, models *models.PullComment, mentions []syntax.DID) {}
-
func (m *BaseNotifier) NewPullState(ctx context.Context, pull *models.Pull) {}
+
func (m *BaseNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {}
func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {}
+4 -2
appview/notify/posthog/notifier.go
···
}
}
-
func (n *posthogNotifier) NewIssueState(ctx context.Context, issue *models.Issue) {
+
func (n *posthogNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
var event string
if issue.Open {
event = "issue_reopen"
···
Event: event,
Properties: posthog.Properties{
"repo_at": issue.RepoAt.String(),
+
"actor": actor,
"issue_id": issue.IssueId,
},
})
···
}
}
-
func (n *posthogNotifier) NewPullState(ctx context.Context, pull *models.Pull) {
+
func (n *posthogNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
var event string
switch pull.State {
case models.PullClosed:
···
Properties: posthog.Properties{
"repo_at": pull.RepoAt,
"pull_id": pull.PullId,
+
"actor": actor,
},
})
if err != nil {
+4 -3
appview/pulls/pulls.go
···
func (s *Pulls) MergePull(w http.ResponseWriter, r *http.Request) {
+
user := s.oauth.GetUser(r)
f, err := s.repoResolver.Resolve(r)
if err != nil {
log.Println("failed to resolve repo:", err)
···
// notify about the pull merge
for _, p := range pullsToMerge {
-
s.notifier.NewPullState(r.Context(), p)
+
s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p)
s.pages.HxLocation(w, fmt.Sprintf("/@%s/%s/pulls/%d", f.OwnerHandle(), f.Name, pull.PullId))
···
for _, p := range pullsToClose {
-
s.notifier.NewPullState(r.Context(), p)
+
s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p)
s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId))
···
for _, p := range pullsToReopen {
-
s.notifier.NewPullState(r.Context(), p)
+
s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p)
s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId))