--- a/pkg/connector/chatinfo.go +++ b/pkg/connector/chatinfo.go @@ -2,6 +2,7 @@ import ( "context" + "errors" "fmt" "time" @@ -22,7 +23,9 @@ func (m *MetaClient) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error) { meta := portal.Metadata.(*metaid.PortalMetadata) if !meta.ThreadType.IsWhatsApp() { - return nil, fmt.Errorf("getting chat info for non-whatsapp threads is not supported") + // Xessenger: errors.ErrUnsupported tells a caller that this thread's info comes only with + // thread sync, not that Messenger failed (services/bridgekit/migrate moveChatInfo). + return nil, fmt.Errorf("getting chat info for non-whatsapp threads is not supported: %w", errors.ErrUnsupported) } jid := meta.JID(portal.ID) switch jid.Server { --- /dev/null +++ b/pkg/connector/xessenger_chatinfo_test.go @@ -0,0 +1,25 @@ +package connector + +import ( + "context" + "errors" + "testing" + + "maunium.net/go/mautrix/bridgev2" + "maunium.net/go/mautrix/bridgev2/database" + + "go.mau.fi/mautrix-meta/pkg/messagix/table" + "go.mau.fi/mautrix-meta/pkg/metaid" +) + +// A Messenger thread's info comes only with thread sync: asked for it, the connector says the request is +// unsupported (errors.ErrUnsupported), which a history move takes as its cue to use what the bridge holds. +func TestXessengerChatInfoOfMessengerThreadIsUnsupported(t *testing.T) { + for _, threadType := range []table.ThreadType{table.ONE_TO_ONE, table.GROUP_THREAD} { + portal := &bridgev2.Portal{Portal: &database.Portal{Metadata: &metaid.PortalMetadata{ThreadType: threadType}}} + info, err := (&MetaClient{}).GetChatInfo(context.Background(), portal) + if info != nil || !errors.Is(err, errors.ErrUnsupported) { + t.Fatalf("thread type %d answered %v, %v; want errors.ErrUnsupported", threadType, info, err) + } + } +}