forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

appview/{pulls,issues}: more notifications

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.sh>

authored by anirudh.fi and committed by anirudh.fi b2857c26 d63d6fc5

Changed files
+33
appview
+8
appview/issues/issues.go
··· 301 return 302 } 303 304 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId)) 305 return 306 } else { ··· 434 435 // reset atUri to make rollback a no-op 436 atUri = "" 437 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d#comment-%d", f.OwnerSlashRepo(), issue.IssueId, commentId)) 438 } 439
··· 301 return 302 } 303 304 + // notify about the issue closure 305 + rp.notifier.NewIssueClosed(r.Context(), issue) 306 + 307 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId)) 308 return 309 } else { ··· 437 438 // reset atUri to make rollback a no-op 439 atUri = "" 440 + 441 + // notify about the new comment 442 + comment.Id = commentId 443 + rp.notifier.NewIssueComment(r.Context(), &comment) 444 + 445 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d#comment-%d", f.OwnerSlashRepo(), issue.IssueId, commentId)) 446 } 447
+12
appview/notify/merged_notifier.go
··· 72 } 73 } 74 75 func (m *mergedNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) { 76 for _, notifier := range m.notifiers { 77 notifier.UpdateProfile(ctx, profile)
··· 72 } 73 } 74 75 + func (m *mergedNotifier) NewPullMerged(ctx context.Context, pull *models.Pull) { 76 + for _, notifier := range m.notifiers { 77 + notifier.NewPullMerged(ctx, pull) 78 + } 79 + } 80 + 81 + func (m *mergedNotifier) NewPullClosed(ctx context.Context, pull *models.Pull) { 82 + for _, notifier := range m.notifiers { 83 + notifier.NewPullClosed(ctx, pull) 84 + } 85 + } 86 + 87 func (m *mergedNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) { 88 for _, notifier := range m.notifiers { 89 notifier.UpdateProfile(ctx, profile)
+4
appview/notify/notifier.go
··· 21 22 NewPull(ctx context.Context, pull *models.Pull) 23 NewPullComment(ctx context.Context, comment *models.PullComment) 24 25 UpdateProfile(ctx context.Context, profile *models.Profile) 26 ··· 48 49 func (m *BaseNotifier) NewPull(ctx context.Context, pull *models.Pull) {} 50 func (m *BaseNotifier) NewPullComment(ctx context.Context, models *models.PullComment) {} 51 52 func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {} 53
··· 21 22 NewPull(ctx context.Context, pull *models.Pull) 23 NewPullComment(ctx context.Context, comment *models.PullComment) 24 + NewPullMerged(ctx context.Context, pull *models.Pull) 25 + NewPullClosed(ctx context.Context, pull *models.Pull) 26 27 UpdateProfile(ctx context.Context, profile *models.Profile) 28 ··· 50 51 func (m *BaseNotifier) NewPull(ctx context.Context, pull *models.Pull) {} 52 func (m *BaseNotifier) NewPullComment(ctx context.Context, models *models.PullComment) {} 53 + func (m *BaseNotifier) NewPullMerged(ctx context.Context, pull *models.Pull) {} 54 + func (m *BaseNotifier) NewPullClosed(ctx context.Context, pull *models.Pull) {} 55 56 func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {} 57
+9
appview/pulls/pulls.go
··· 2147 return 2148 } 2149 2150 s.pages.HxLocation(w, fmt.Sprintf("/@%s/%s/pulls/%d", f.OwnerHandle(), f.Name, pull.PullId)) 2151 } 2152 ··· 2212 log.Println("failed to commit transaction", err) 2213 s.pages.Notice(w, "pull-close", "Failed to close pull.") 2214 return 2215 } 2216 2217 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId))
··· 2147 return 2148 } 2149 2150 + // notify about the pull merge 2151 + for _, p := range pullsToMerge { 2152 + s.notifier.NewPullMerged(r.Context(), p) 2153 + } 2154 + 2155 s.pages.HxLocation(w, fmt.Sprintf("/@%s/%s/pulls/%d", f.OwnerHandle(), f.Name, pull.PullId)) 2156 } 2157 ··· 2217 log.Println("failed to commit transaction", err) 2218 s.pages.Notice(w, "pull-close", "Failed to close pull.") 2219 return 2220 + } 2221 + 2222 + for _, p := range pullsToClose { 2223 + s.notifier.NewPullClosed(r.Context(), p) 2224 } 2225 2226 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId))