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 (
1717
 	"github.com/tenseleyFlow/shithub/internal/issues"
1818
 	issuesdb "github.com/tenseleyFlow/shithub/internal/issues/sqlc"
1919
 	reposdb "github.com/tenseleyFlow/shithub/internal/repos/sqlc"
20
+	"github.com/tenseleyFlow/shithub/internal/social"
2021
 	"github.com/tenseleyFlow/shithub/internal/web/middleware"
2122
 )
2223
 
@@ -196,6 +197,11 @@ func (h *Handlers) issueCreate(w http.ResponseWriter, r *http.Request) {
196197
 		h.renderIssueCreateError(w, r, owner.Username, row, title, body, err)
197198
 		return
198199
 	}
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)
199205
 	http.Redirect(w, r,
200206
 		"/"+owner.Username+"/"+row.Name+"/issues/"+strconv.FormatInt(created.Number, 10),
201207
 		http.StatusSeeOther,
@@ -351,6 +357,8 @@ func (h *Handlers) issueComment(w http.ResponseWriter, r *http.Request) {
351357
 		h.handleIssueWriteError(w, r, owner.Username, row, issue, err)
352358
 		return
353359
 	}
360
+	// Auto-watch on first involvement (S26).
361
+	_ = social.AutoWatchOnInvolvement(r.Context(), h.socialDeps(), viewer.ID, row.ID)
354362
 	h.redirectIssue(w, r, owner.Username, row.Name, issue.Number)
355363
 }
356364
 
internal/web/handlers/repo/pulls.gomodified
@@ -23,6 +23,7 @@ import (
2323
 	repogit "github.com/tenseleyFlow/shithub/internal/repos/git"
2424
 	mdrender "github.com/tenseleyFlow/shithub/internal/markdown"
2525
 	reposdb "github.com/tenseleyFlow/shithub/internal/repos/sqlc"
26
+	"github.com/tenseleyFlow/shithub/internal/social"
2627
 	"github.com/tenseleyFlow/shithub/internal/web/middleware"
2728
 	"github.com/tenseleyFlow/shithub/internal/worker"
2829
 )
@@ -179,6 +180,10 @@ func (h *Handlers) pullCreate(w http.ResponseWriter, r *http.Request) {
179180
 		h.handlePullCreateError(w, r, owner.Username, row, err)
180181
 		return
181182
 	}
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)
182187
 	// Kick off the mergeability probe right away.
183188
 	if _, err := worker.Enqueue(r.Context(), h.d.Pool, worker.KindPRMergeability,
184189
 		map[string]any{"pr_id": res.PullRequest.IssueID}, worker.EnqueueOptions{}); err != nil {