business: fix contact projection and phone sharing
(cherry picked from commit c0a0e5b52240ed415d3b43ba77659821887bf50b)
This commit is contained in:
parent
d84fa6e126
commit
860e581d06
18 changed files with 703 additions and 36 deletions
31
internal/rpc/convert_test.go
Normal file
31
internal/rpc/convert_test.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gotd/td/tg"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
func TestTGMessagesMessagesMarksViewerSelfAndKeepsProjectedPhone(t *testing.T) {
|
||||
const viewerID int64 = 1001
|
||||
res := tgMessagesMessages(viewerID, domain.MessageList{
|
||||
Users: []domain.User{
|
||||
{ID: viewerID, AccessHash: 11, Phone: "15550000001", FirstName: "Owner"},
|
||||
{ID: 1002, AccessHash: 22, Phone: "", FirstName: "Peer"},
|
||||
},
|
||||
})
|
||||
full, ok := res.(*tg.MessagesMessages)
|
||||
if !ok {
|
||||
t.Fatalf("result = %T, want *tg.MessagesMessages", res)
|
||||
}
|
||||
self, ok := full.Users[0].(*tg.User)
|
||||
if !ok || !self.Self || self.Phone != "15550000001" {
|
||||
t.Fatalf("self user = %+v ok=%v, want self with phone", full.Users[0], ok)
|
||||
}
|
||||
peer, ok := full.Users[1].(*tg.User)
|
||||
if !ok || peer.Self || peer.Phone != "" || peer.FirstName != "Peer" {
|
||||
t.Fatalf("peer user = %+v ok=%v, want projected non-self without phone", full.Users[1], ok)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue