feat: extract groups from message logs

This commit is contained in:
zhaoyilun
2026-07-09 23:42:56 +08:00
parent 7e616a1f10
commit 4502a05bb4
4 changed files with 172 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
package isphere
import (
"reflect"
"testing"
)
func TestSearchGroupsFromMessagesMatchesGroupchatJIDs(t *testing.T) {
messages := []Message{
{ID: "msg-1", ConversationType: "groupchat", SenderID: "project-room@conference.imopenfire1-lanzhou", ReceiverID: "user@imopenfire1-lanzhou"},
{ID: "msg-2", ConversationType: "chat", SenderID: "alice@imopenfire1-lanzhou", ReceiverID: "bob@imopenfire1-lanzhou"},
{ID: "msg-3", ConversationType: "groupchat", SenderID: "project-room@conference.imopenfire1-lanzhou", ReceiverID: "other@imopenfire1-lanzhou"},
}
got := SearchGroupsFromMessages(messages, SearchGroupsQuery{Query: "project", Limit: 10})
want := SearchGroupsResult{Groups: []Group{
{GroupID: "project-room@conference.imopenfire1-lanzhou", DisplayName: "project-room@conference.imopenfire1-lanzhou", Source: "local_readonly", Confidence: 0.6, RawRef: "groupchat_jid"},
}}
if !reflect.DeepEqual(got, want) {
t.Fatalf("SearchGroupsFromMessages() = %#v, want %#v", got, want)
}
}