Publish Discord inbound replies on the post event bus.
CI / test (pull_request) Successful in 6m21s

This commit is contained in:
2026-08-29 11:38:11 -07:00
parent a1b0351048
commit 2b3aac413d
5 changed files with 66 additions and 55 deletions
+6 -5
View File
@@ -27,9 +27,11 @@ func TestInboundCreatesSiteReply(t *testing.T) {
links := newMemoryLinks()
api := &fakeAPI{}
mailer := &mail.Recording{}
bot := inboundTestBot(mem, links, api, mailer, admin.Username)
bot := inboundTestBot(mem, links, api, admin.Username)
bus := events.New()
defer bus.Close()
bot.bus = bus
mail.Subscribe(bus, mem, mailer)
bus.Subscribe(bot.Handle)
root := seedLinkedRoot(t, mem, links, homeowner.ID, "thread-1")
@@ -68,7 +70,7 @@ func TestInboundParentsFromReference(t *testing.T) {
mem, homeowner, admin := seedInboundUsers(t)
links := newMemoryLinks()
bot := inboundTestBot(mem, links, &fakeAPI{}, &mail.Recording{}, admin.Username)
bot := inboundTestBot(mem, links, &fakeAPI{}, admin.Username)
root := seedLinkedRoot(t, mem, links, homeowner.ID, "thread-1")
plumberReply := &store.Post{ParentID: &root.ID, AuthorID: admin.ID, Body: "First look."}
if err := mem.CreatePost(context.Background(), plumberReply); err != nil {
@@ -106,7 +108,7 @@ func TestInboundIgnoresAllowlistHiddenAndEchoSources(t *testing.T) {
mem, homeowner, admin := seedInboundUsers(t)
links := newMemoryLinks()
api := &fakeAPI{}
bot := inboundTestBot(mem, links, api, mail.Nop{}, admin.Username)
bot := inboundTestBot(mem, links, api, admin.Username)
root := seedLinkedRoot(t, mem, links, homeowner.ID, "thread-1")
hidden := &store.Post{
AuthorID: homeowner.ID,
@@ -148,10 +150,9 @@ func TestInboundIgnoresAllowlistHiddenAndEchoSources(t *testing.T) {
}
}
func inboundTestBot(mem *store.Memory, links *memoryLinks, api *fakeAPI, mailer mail.Notifier, adminUsername string) *Bot {
func inboundTestBot(mem *store.Memory, links *memoryLinks, api *fakeAPI, adminUsername string) *Bot {
bot := New("channel-1", links, api)
bot.store = mem
bot.mail = mailer
bot.admins = map[string]string{"snow-admin": adminUsername}
bot.botUserID = "bot-1"
return bot