forked from tangled.org/core
Monorepo for Tangled

appview/{pulls,issues}: more notifications

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

authored by anirudh.fi and committed by Tangled 6b79572a 504d86f9

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