Skip to content

Commit df8c9a5

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
Add PR reminder feature
1 parent 69d2e55 commit df8c9a5

19 files changed

+1664
-67
lines changed

cmd/server/main.go

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,7 @@ func run(ctx context.Context, cancel context.CancelFunc, cfg *config.ServerConfi
162162
slackManager := slack.NewManager(cfg.SlackSigningSecret)
163163

164164
// Initialize state store (in-memory + Datastore or JSON for persistence).
165-
//nolint:interfacebloat // Interface mirrors state.Store for local type safety
166-
var stateStore interface {
167-
Thread(owner, repo string, number int, channelID string) (state.ThreadInfo, bool)
168-
SaveThread(owner, repo string, number int, channelID string, info state.ThreadInfo) error
169-
LastDM(userID, prURL string) (time.Time, bool)
170-
RecordDM(userID, prURL string, sentAt time.Time) error
171-
DMMessage(userID, prURL string) (state.DMInfo, bool)
172-
SaveDMMessage(userID, prURL string, info state.DMInfo) error
173-
ListDMUsers(prURL string) []string
174-
LastDigest(userID, date string) (time.Time, bool)
175-
RecordDigest(userID, date string, sentAt time.Time) error
176-
WasProcessed(eventKey string) bool
177-
MarkProcessed(eventKey string, ttl time.Duration) error
178-
LastNotification(prURL string) time.Time
179-
RecordNotification(prURL string, notifiedAt time.Time) error
180-
Cleanup() error
181-
Close() error
182-
}
165+
var stateStore state.Store
183166

184167
// Check if Datastore should be used via DATASTORE=<database-id>
185168
// Examples:
@@ -256,7 +239,7 @@ func run(ctx context.Context, cancel context.CancelFunc, cfg *config.ServerConfi
256239
slog.Info("configured Slack manager with state store for DM tracking")
257240

258241
// Initialize notification manager for multi-workspace notifications.
259-
notifier := notify.New(notify.WrapSlackManager(slackManager), configManager)
242+
notifier := notify.New(notify.WrapSlackManager(slackManager), configManager, stateStore)
260243

261244
// Initialize event router for multi-workspace event handling.
262245
eventRouter := slack.NewEventRouter(slackManager)
@@ -679,23 +662,7 @@ func runBotCoordinators(
679662
githubManager *github.Manager,
680663
configManager *config.Manager,
681664
notifier *notify.Manager,
682-
stateStore interface {
683-
Thread(owner, repo string, number int, channelID string) (state.ThreadInfo, bool)
684-
SaveThread(owner, repo string, number int, channelID string, info state.ThreadInfo) error
685-
LastDM(userID, prURL string) (time.Time, bool)
686-
RecordDM(userID, prURL string, sentAt time.Time) error
687-
DMMessage(userID, prURL string) (state.DMInfo, bool)
688-
SaveDMMessage(userID, prURL string, info state.DMInfo) error
689-
ListDMUsers(prURL string) []string
690-
LastDigest(userID, date string) (time.Time, bool)
691-
RecordDigest(userID, date string, sentAt time.Time) error
692-
WasProcessed(eventKey string) bool
693-
MarkProcessed(eventKey string, ttl time.Duration) error
694-
LastNotification(prURL string) time.Time
695-
RecordNotification(prURL string, notifiedAt time.Time) error
696-
Cleanup() error
697-
Close() error
698-
},
665+
stateStore state.Store,
699666
sprinklerURL string,
700667
) error {
701668
cm := &coordinatorManager{

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ require (
2626
github.com/cloudflare/circl v1.6.1 // indirect
2727
github.com/google/go-cmp v0.7.0 // indirect
2828
github.com/google/go-querystring v1.1.0 // indirect
29+
github.com/google/uuid v1.6.0 // indirect
2930
github.com/gorilla/websocket v1.5.3 // indirect
3031
github.com/kr/pretty v0.3.1 // indirect
3132
github.com/rogpeppe/go-internal v1.14.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ github.com/google/go-github/v50 v50.2.0 h1:j2FyongEHlO9nxXLc+LP3wuBSVU9mVxfpdYUe
3030
github.com/google/go-github/v50 v50.2.0/go.mod h1:VBY8FB6yPIjrtKhozXv4FQupxKLS6H4m6xFZlT43q8Q=
3131
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
3232
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
33+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
34+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
3335
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
3436
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
3537
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=

pkg/bot/integration_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/codeGROOVE-dev/slacker/pkg/notify"
1111
"github.com/codeGROOVE-dev/slacker/pkg/slack"
1212
"github.com/codeGROOVE-dev/slacker/pkg/slacktest"
13+
"github.com/codeGROOVE-dev/slacker/pkg/state"
1314
"github.com/codeGROOVE-dev/slacker/pkg/usermapping"
1415
"github.com/codeGROOVE-dev/turnclient/pkg/turn"
1516
slackapi "github.com/slack-go/slack"
@@ -231,7 +232,10 @@ func TestDMDelayLogicIntegration(t *testing.T) {
231232
dmDelay: 65, // 65 minute delay
232233
}
233234

234-
notifier := notify.New(notify.WrapSlackManager(slackManager), configMgr)
235+
// Create in-memory store for pending DMs
236+
store := state.NewMemoryStore()
237+
238+
notifier := notify.New(notify.WrapSlackManager(slackManager), configMgr, store)
235239

236240
prInfo := notify.PRInfo{
237241
Owner: "test",
@@ -291,7 +295,8 @@ func TestDMDelayLogicIntegration(t *testing.T) {
291295
// Create fresh tracker with initialized maps
292296
notifier.Tracker = &notify.NotificationTracker{}
293297
// Initialize the tracker by creating a new notifier
294-
notifier = notify.New(notify.WrapSlackManager(slackManager), configMgr)
298+
store = state.NewMemoryStore() // Reset store as well
299+
notifier = notify.New(notify.WrapSlackManager(slackManager), configMgr, store)
295300

296301
// Setup test scenario
297302
if tt.setupFunc != nil {

pkg/home/fetcher_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,18 @@ func (m *mockStateStore) Cleanup() error {
260260
return nil
261261
}
262262

263+
func (m *mockStateStore) QueuePendingDM(dm state.PendingDM) error {
264+
return nil
265+
}
266+
267+
func (m *mockStateStore) GetPendingDMs(before time.Time) ([]state.PendingDM, error) {
268+
return nil, nil
269+
}
270+
271+
func (m *mockStateStore) RemovePendingDM(id string) error {
272+
return nil
273+
}
274+
263275
func (m *mockStateStore) Close() error {
264276
return nil
265277
}

pkg/notify/daily_digest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ func TestNewDailyDigestScheduler_FactoryWorks(t *testing.T) {
603603
mockConfigMgr := &mockConfigProvider{}
604604
mockState := &mockStateProvider{}
605605
mockSlack := &mockSlackManagerWithClient{}
606-
manager := New(mockSlack, mockConfigMgr)
606+
manager := New(mockSlack, mockConfigMgr, &mockStore{})
607607

608608
scheduler := NewDailyDigestScheduler(manager, mockGitHubMgr, mockConfigMgr, mockState, mockSlack)
609609

pkg/notify/daily_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ func TestNewDailyDigestScheduler_WithInterfaces(t *testing.T) {
472472
mockConfigMgr := &mockConfigProvider{}
473473
mockState := &mockStateProvider{}
474474
mockSlack := &mockSlackManagerWithClient{}
475-
manager := New(mockSlack, mockConfigMgr)
475+
manager := New(mockSlack, mockConfigMgr, &mockStore{})
476476

477477
scheduler := NewDailyDigestScheduler(manager, mockGitHubMgr, mockConfigMgr, mockState, mockSlack)
478478

pkg/notify/format_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ func TestNew(t *testing.T) {
584584
mockConfig := &mockConfigManager{}
585585

586586
// Call New - it should not panic
587-
manager := New(nil, mockConfig)
587+
manager := New(nil, mockConfig, &mockStore{})
588588

589589
if manager == nil {
590590
t.Fatal("expected non-nil manager")
@@ -604,7 +604,7 @@ func TestNewDailyDigestScheduler(t *testing.T) {
604604
mockConfig := &mockConfigManager{}
605605
mockState := &mockStateProvider{}
606606
mockSlack := &mockSlackManager{}
607-
manager := New(nil, mockConfig)
607+
manager := New(nil, mockConfig, &mockStore{})
608608

609609
scheduler := NewDailyDigestScheduler(manager, nil, mockConfig, mockState, mockSlack)
610610

0 commit comments

Comments
 (0)