Change Peers to * Peers in identity to retrieve pointer to the real peer
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		@@ -71,7 +71,7 @@ func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerU
 | 
			
		||||
	peer.MyPullServers = MessageServerUids
 | 
			
		||||
	peer.MyName = MyName
 | 
			
		||||
	peer.InvitationMessage = InvitationMessage
 | 
			
		||||
	id.Peers = append(id.Peers, peer)
 | 
			
		||||
	id.Peers = append(id.Peers, &peer)
 | 
			
		||||
 | 
			
		||||
	return &peer, nil
 | 
			
		||||
}
 | 
			
		||||
@@ -120,7 +120,7 @@ func (id *Identity) AnswerInvitation(MyName string, ContactName string, MessageS
 | 
			
		||||
	peer.MyPullServers = MessageServerIdxs
 | 
			
		||||
	peer.MyName = MyName
 | 
			
		||||
	peer.InvitationId = ReceivedContact.InvitationId
 | 
			
		||||
	id.Peers = append(id.Peers, peer)
 | 
			
		||||
	id.Peers = append(id.Peers, &peer)
 | 
			
		||||
 | 
			
		||||
	return &peer
 | 
			
		||||
}
 | 
			
		||||
@@ -189,7 +189,7 @@ func (id *Identity) TryUnlockHidden(password string) error {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
			p.dbPassword = password
 | 
			
		||||
			id.unlockedHiddenPeers = append(id.unlockedHiddenPeers, p)
 | 
			
		||||
			id.unlockedHiddenPeers = append(id.unlockedHiddenPeers, &p)
 | 
			
		||||
			found = true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -229,7 +229,7 @@ func (id *Identity) generateRandomHiddenStuff() {
 | 
			
		||||
		p.ContactEncryption = p.MyIdentity.Public
 | 
			
		||||
		p.ContactLookupKey = p.MyEncryptionKp.Public
 | 
			
		||||
		//	p.Contact.AddUrls([]string{randomLenString(14, 60), randomLenString(14, 60)}) // todo add servers
 | 
			
		||||
		id.Peers = append(id.Peers, p)
 | 
			
		||||
		id.Peers = append(id.Peers, &p)
 | 
			
		||||
		id.HidePeer(0, randomLenString(8, 14))
 | 
			
		||||
		// TODO Add random conversations
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ func createId() *Identity {
 | 
			
		||||
	p.ContactEncryption = p.MyIdentity.Public
 | 
			
		||||
	p.ContactLookupKey = p.MyEncryptionKp.Public
 | 
			
		||||
	//p.Contact.AddUrls([]string{"http:/127.0.0.1/meow", "tcp://localhost:1234"}) //todo add servers
 | 
			
		||||
	id.Peers = append(id.Peers, p)
 | 
			
		||||
	id.Peers = append(id.Peers, &p)
 | 
			
		||||
	return id
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -85,7 +85,7 @@ func TestHidePeer(t *testing.T) {
 | 
			
		||||
func TestGetRequestJobs(t *testing.T) {
 | 
			
		||||
	// Create a mock Identity object
 | 
			
		||||
	id := &Identity{
 | 
			
		||||
		Peers: []Peer{
 | 
			
		||||
		Peers: []*Peer{
 | 
			
		||||
			{
 | 
			
		||||
				MyPullServers: []string{"server1", "server2"},
 | 
			
		||||
				MyLookupKp:    meowlib.NewKeyPair(),
 | 
			
		||||
@@ -95,7 +95,7 @@ func TestGetRequestJobs(t *testing.T) {
 | 
			
		||||
				MyLookupKp:    meowlib.NewKeyPair(),
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		unlockedHiddenPeers: []Peer{
 | 
			
		||||
		unlockedHiddenPeers: []*Peer{
 | 
			
		||||
			{
 | 
			
		||||
				MyPullServers: []string{"server5", "server6"},
 | 
			
		||||
				MyLookupKp:    meowlib.NewKeyPair(),
 | 
			
		||||
 
 | 
			
		||||
@@ -8,17 +8,17 @@ const (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type InternalUserMessage struct {
 | 
			
		||||
	Outbound           bool // 0 = inbound, 1 = outbound
 | 
			
		||||
	Messagetype        string
 | 
			
		||||
	Message            string
 | 
			
		||||
	ConversationStatus *meowlib.ConversationStatus
 | 
			
		||||
	Contact            *meowlib.ContactCard
 | 
			
		||||
	Outbound           bool                        `json:"outbound,omitempty"` // 0 = inbound, 1 = outbound
 | 
			
		||||
	Messagetype        string                      `json:"messagetype,omitempty"`
 | 
			
		||||
	Message            string                      `json:"message,omitempty"`
 | 
			
		||||
	ConversationStatus *meowlib.ConversationStatus `json:"conversation_status,omitempty"`
 | 
			
		||||
	Contact            *meowlib.ContactCard        `json:"contact,omitempty"`
 | 
			
		||||
	//Group group
 | 
			
		||||
	FilePaths       []string
 | 
			
		||||
	CurrentLocation *meowlib.Location
 | 
			
		||||
	Appdata         []byte
 | 
			
		||||
	Dbfile          string
 | 
			
		||||
	Dbid            int64
 | 
			
		||||
	FilePaths       []string          `json:"file_paths,omitempty"`
 | 
			
		||||
	CurrentLocation *meowlib.Location `json:"current_location,omitempty"`
 | 
			
		||||
	Appdata         []byte            `json:"appdata,omitempty"`
 | 
			
		||||
	Dbfile          string            `json:"dbfile,omitempty"`
 | 
			
		||||
	Dbid            int64             `json:"dbid,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// InternalUserMessageFromUserMessage creates an InternalUserMessage from a UserMessage
 | 
			
		||||
 
 | 
			
		||||
@@ -14,11 +14,11 @@ func TestStoreMessage(t *testing.T) {
 | 
			
		||||
	id := createId()
 | 
			
		||||
	var um meowlib.UserMessage
 | 
			
		||||
	um.Data = []byte("blabla")
 | 
			
		||||
	err := StoreMessage(&id.Peers[0], &um, []string{}, GetConfig().memoryPassword)
 | 
			
		||||
	err := StoreMessage(id.Peers[0], &um, []string{}, GetConfig().memoryPassword)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	messages, err := GetMessagesHistory(&id.Peers[0], 0, 0, 10, GetConfig().memoryPassword)
 | 
			
		||||
	messages, err := GetMessagesHistory(id.Peers[0], 0, 0, 10, GetConfig().memoryPassword)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -45,12 +45,12 @@ func TestManyStoreMessage(t *testing.T) {
 | 
			
		||||
	for i := 1; i < 100; i++ {
 | 
			
		||||
		var um meowlib.UserMessage
 | 
			
		||||
		um.Data = []byte(randomLenString(20, 200))
 | 
			
		||||
		err := StoreMessage(&id.Peers[0], &um, []string{}, GetConfig().memoryPassword)
 | 
			
		||||
		err := StoreMessage(id.Peers[0], &um, []string{}, GetConfig().memoryPassword)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	messages, err := GetMessagesHistory(&id.Peers[0], 0, 0, 10, GetConfig().memoryPassword)
 | 
			
		||||
	messages, err := GetMessagesHistory(id.Peers[0], 0, 0, 10, GetConfig().memoryPassword)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ func TestGetFromPublicKey(t *testing.T) {
 | 
			
		||||
		var p Peer
 | 
			
		||||
		p.Name = "test" + strconv.Itoa(i)
 | 
			
		||||
		p.ContactPublicKey = "stringToFind" + strconv.Itoa(i)
 | 
			
		||||
		id.Peers = append(id.Peers, p)
 | 
			
		||||
		id.Peers = append(id.Peers, &p)
 | 
			
		||||
	}
 | 
			
		||||
	p5 := id.Peers.GetFromPublicKey("stringToFind5")
 | 
			
		||||
	assert.Equal(t, p5.Name, "test5")
 | 
			
		||||
 
 | 
			
		||||
@@ -4,12 +4,12 @@ import (
 | 
			
		||||
	"forge.redroom.link/yves/meowlib"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PeerList []Peer
 | 
			
		||||
type PeerList []*Peer
 | 
			
		||||
 | 
			
		||||
func (pl *PeerList) GetFromPublicKey(publickey string) *Peer {
 | 
			
		||||
	for _, peer := range *pl {
 | 
			
		||||
		if peer.ContactPublicKey == publickey {
 | 
			
		||||
			return &peer
 | 
			
		||||
			return peer
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
@@ -18,7 +18,7 @@ func (pl *PeerList) GetFromPublicKey(publickey string) *Peer {
 | 
			
		||||
func (pl *PeerList) GetFromMyLookupKey(publickey string) *Peer {
 | 
			
		||||
	for _, peer := range *pl {
 | 
			
		||||
		if peer.MyLookupKp.Public == publickey {
 | 
			
		||||
			return &peer
 | 
			
		||||
			return peer
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
@@ -27,7 +27,7 @@ func (pl *PeerList) GetFromMyLookupKey(publickey string) *Peer {
 | 
			
		||||
func (pl *PeerList) GetFromName(name string) *Peer {
 | 
			
		||||
	for _, peer := range *pl {
 | 
			
		||||
		if peer.Name == name {
 | 
			
		||||
			return &peer
 | 
			
		||||
			return peer
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user