tenseleyflow/shithub / 7e36f18

Browse files

S26: wire AutoWatchOnInvolvement into issue/PR create + comment paths

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
7e36f1848384cf5c8f5b0f3a260cc2bf6dcd2cf6
Parents
7746dad
Tree
1a01f7f

2 changed files

StatusFile+-
M internal/web/handlers/repo/issues.go 8 0
M internal/web/handlers/repo/pulls.go 5 0
internal/web/handlers/repo/issues.gomodified
@@ -17,6 +17,7 @@ import (
17
 	"github.com/tenseleyFlow/shithub/internal/issues"
17
 	"github.com/tenseleyFlow/shithub/internal/issues"
18
 	issuesdb "github.com/tenseleyFlow/shithub/internal/issues/sqlc"
18
 	issuesdb "github.com/tenseleyFlow/shithub/internal/issues/sqlc"
19
 	reposdb "github.com/tenseleyFlow/shithub/internal/repos/sqlc"
19
 	reposdb "github.com/tenseleyFlow/shithub/internal/repos/sqlc"
20
+	"github.com/tenseleyFlow/shithub/internal/social"
20
 	"github.com/tenseleyFlow/shithub/internal/web/middleware"
21
 	"github.com/tenseleyFlow/shithub/internal/web/middleware"
21
 )
22
 )
22
 
23
 
@@ -196,6 +197,11 @@ func (h *Handlers) issueCreate(w http.ResponseWriter, r *http.Request) {
196
 		h.renderIssueCreateError(w, r, owner.Username, row, title, body, err)
197
 		h.renderIssueCreateError(w, r, owner.Username, row, title, body, err)
197
 		return
198
 		return
198
 	}
199
 	}
200
+	// Auto-watch on first involvement (S26): subscribe the author at
201
+	// `participating` so notifications fan-out (S29) routes future
202
+	// thread events to them. Non-destructive — no-op if the user
203
+	// already has an explicit preference.
204
+	_ = social.AutoWatchOnInvolvement(r.Context(), h.socialDeps(), viewer.ID, row.ID)
199
 	http.Redirect(w, r,
205
 	http.Redirect(w, r,
200
 		"/"+owner.Username+"/"+row.Name+"/issues/"+strconv.FormatInt(created.Number, 10),
206
 		"/"+owner.Username+"/"+row.Name+"/issues/"+strconv.FormatInt(created.Number, 10),
201
 		http.StatusSeeOther,
207
 		http.StatusSeeOther,
@@ -351,6 +357,8 @@ func (h *Handlers) issueComment(w http.ResponseWriter, r *http.Request) {
351
 		h.handleIssueWriteError(w, r, owner.Username, row, issue, err)
357
 		h.handleIssueWriteError(w, r, owner.Username, row, issue, err)
352
 		return
358
 		return
353
 	}
359
 	}
360
+	// Auto-watch on first involvement (S26).
361
+	_ = social.AutoWatchOnInvolvement(r.Context(), h.socialDeps(), viewer.ID, row.ID)
354
 	h.redirectIssue(w, r, owner.Username, row.Name, issue.Number)
362
 	h.redirectIssue(w, r, owner.Username, row.Name, issue.Number)
355
 }
363
 }
356
 
364
 
internal/web/handlers/repo/pulls.gomodified
@@ -23,6 +23,7 @@ import (
23
 	repogit "github.com/tenseleyFlow/shithub/internal/repos/git"
23
 	repogit "github.com/tenseleyFlow/shithub/internal/repos/git"
24
 	mdrender "github.com/tenseleyFlow/shithub/internal/markdown"
24
 	mdrender "github.com/tenseleyFlow/shithub/internal/markdown"
25
 	reposdb "github.com/tenseleyFlow/shithub/internal/repos/sqlc"
25
 	reposdb "github.com/tenseleyFlow/shithub/internal/repos/sqlc"
26
+	"github.com/tenseleyFlow/shithub/internal/social"
26
 	"github.com/tenseleyFlow/shithub/internal/web/middleware"
27
 	"github.com/tenseleyFlow/shithub/internal/web/middleware"
27
 	"github.com/tenseleyFlow/shithub/internal/worker"
28
 	"github.com/tenseleyFlow/shithub/internal/worker"
28
 )
29
 )
@@ -179,6 +180,10 @@ func (h *Handlers) pullCreate(w http.ResponseWriter, r *http.Request) {
179
 		h.handlePullCreateError(w, r, owner.Username, row, err)
180
 		h.handlePullCreateError(w, r, owner.Username, row, err)
180
 		return
181
 		return
181
 	}
182
 	}
183
+	// Auto-watch on first involvement (S26): subscribe the PR author
184
+	// at `participating` so notifications fan-out routes future
185
+	// thread events to them.
186
+	_ = social.AutoWatchOnInvolvement(r.Context(), h.socialDeps(), viewer.ID, row.ID)
182
 	// Kick off the mergeability probe right away.
187
 	// Kick off the mergeability probe right away.
183
 	if _, err := worker.Enqueue(r.Context(), h.d.Pool, worker.KindPRMergeability,
188
 	if _, err := worker.Enqueue(r.Context(), h.d.Pool, worker.KindPRMergeability,
184
 		map[string]any{"pr_id": res.PullRequest.IssueID}, worker.EnqueueOptions{}); err != nil {
189
 		map[string]any{"pr_id": res.PullRequest.IssueID}, worker.EnqueueOptions{}); err != nil {