making use of the extended perms and added future work

This commit is contained in:
ari committed 2026-11-01 13:55:25 -05:00
1 parent 296e465f48
commit 22fd8fbce8
19 files changed
+617 -40

No files matched your search

+28
View File
@@ -1,6 +1,7 @@
package state
import (
"os"
"path/filepath"
"testing"
"time"
@@ -64,3 +65,30 @@ func TestPermissionsSavedAndSeededOnce(t *testing.T) {
t.Fatal("invalid changes must be refused")
}
}
func TestListenModes(t *testing.T) {
path := filepath.Join(t.TempDir(), "state.json")
if err := os.WriteFile(path, []byte(`{"owners":{},"sessions":{"C1/1.0":{"channel":"C1","thread_ts":"1.0","acp_id":"a"}}}`), 0o600); err != nil {
t.Fatal(err)
}
s, err := Open(path)
if err != nil {
t.Fatal(err)
}
if s.ThreadListen("C1", "1.0") != model.ListenMentions {
t.Fatal("old state should default to only-mentions")
}
_ = s.SetChannelListen("C1", model.ListenAll)
if s.ThreadListen("C1", "1.0") != model.ListenAll {
t.Fatal("a thread without its own setting follows the channel")
}
_ = s.SetSessionListen("C1", "1.0", model.ListenMentions)
s2, _ := Open(path)
if s2.ThreadListen("C1", "1.0") != model.ListenMentions || s2.ChannelListen("C1") != model.ListenAll {
t.Fatal("listen settings not saved")
}
if s2.ChannelListen("C2") != model.ListenMentions {
t.Fatal("other channels keep the default")
}
}