peers separate
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc
2024-05-28 16:47:04 +02:00
parent c1883f1524
commit e674a0cb33
11 changed files with 164 additions and 79 deletions

View File

@ -73,12 +73,14 @@ func InvitationCreateMessage(invitationId string, invitationServerUid string, ti
// lookup for peer with "invitation_id"
var myContact *meowlib.ContactCard
for i := 0; i < len(client.GetConfig().GetIdentity().Peers); i++ {
/* for i := 0; i < len(client.GetConfig().GetIdentity().Peers); i++ {
if client.GetConfig().GetIdentity().Peers[i].InvitationId == invitationId {
myContact = client.GetConfig().GetIdentity().Peers[i].GetMyContact()
break
}
}
}*/
peer := client.GetConfig().GetIdentity().Peers.GetFromInvitationId(invitationId)
myContact = peer.GetMyContact()
// todo handle not found !!
// lookup for message server with "invitation_server"
invitationServer, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(invitationServerUid) //.GetServerByIdx(int(jsoninv["invitation_server"].(float64)))
@ -122,14 +124,20 @@ func InvitationCreateReadResponse(invitationServerUid string, invitationResponse
// invitationId: the invitation id of the peer
// url: the url of the invitation we got from the server
func InvitationSetUrlInfo(invitationId string, url string, expiry int64) {
id := client.GetConfig().GetIdentity()
// lookup for peer with "invitation_id"
peer := id.Peers.GetFromInvitationId(invitationId)
peer.InvitationUrl = url
peer.InvitationExpiry = time.Unix(expiry, 0)
id.Peers.StorePeer(peer)
for i := 0; i < len(client.GetConfig().GetIdentity().Peers); i++ {
if client.GetConfig().GetIdentity().Peers[i].InvitationId == invitationId {
client.GetConfig().GetIdentity().Peers[i].InvitationUrl = url
client.GetConfig().GetIdentity().Peers[i].InvitationExpiry = time.Unix(expiry, 0)
break
/* for i := 0; i < len(client.GetConfig().GetIdentity().Peers); i++ {
if client.GetConfig().GetIdentity().Peers[i].InvitationId == invitationId {
client.GetConfig().GetIdentity().Peers[i].InvitationUrl = url
client.GetConfig().GetIdentity().Peers[i].InvitationExpiry = time.Unix(expiry, 0)
break
}
}
}
client.GetConfig().GetIdentity().Save()
client.GetConfig().GetIdentity().Save()*/
}