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