forked from cwtch.im/libcwtch-go
Use localname when loading a profile as public name may not have been set...
This commit is contained in:
parent
2f14966051
commit
0f5d0389ca
10
lib.go
10
lib.go
|
@ -237,7 +237,7 @@ func ReconnectCwtchForeground() {
|
|||
|
||||
settings := utils.ReadGlobalSettings()
|
||||
|
||||
for _,profileOnion := range peerList {
|
||||
for _, profileOnion := range peerList {
|
||||
// fix peerpeercontact message counts
|
||||
contactList := application.GetPeer(profileOnion).GetContacts()
|
||||
for _, handle := range contactList {
|
||||
|
@ -307,7 +307,7 @@ func SendAppEvent(eventJson string) {
|
|||
// Group Experiment Refresh
|
||||
groupHandler, err := groups.ExperimentGate(utils.ReadGlobalSettings().Experiments)
|
||||
if err == nil {
|
||||
for _,profileOnion := range application.ListProfiles() {
|
||||
for _, profileOnion := range application.ListProfiles() {
|
||||
serverListForOnion := groupHandler.GetServerInfoList(application.GetPeer(profileOnion))
|
||||
serversListBytes, _ := json.Marshal(serverListForOnion)
|
||||
eventHandler.Push(event.NewEvent(groups.UpdateServerInfo, map[event.Field]string{"ProfileOnion": profileOnion, groups.ServerList: string(serversListBytes)}))
|
||||
|
@ -317,11 +317,11 @@ func SendAppEvent(eventJson string) {
|
|||
// Explicitly toggle blocking/unblocking of unknown connections for profiles
|
||||
// that have been loaded.
|
||||
if utils.ReadGlobalSettings().BlockUnknownConnections {
|
||||
for _,onion := range application.ListProfiles() {
|
||||
for _, onion := range application.ListProfiles() {
|
||||
application.GetPeer(onion).BlockUnknownConnections()
|
||||
}
|
||||
} else {
|
||||
for _,onion := range application.ListProfiles() {
|
||||
for _, onion := range application.ListProfiles() {
|
||||
application.GetPeer(onion).AllowUnknownConnections()
|
||||
}
|
||||
}
|
||||
|
@ -870,7 +870,7 @@ func c_SetProfileAttribute(profile_ptr *C.char, profile_len C.int, key_ptr *C.ch
|
|||
func SetProfileAttribute(profileOnion string, key string, value string) {
|
||||
profile := application.GetPeer(profileOnion)
|
||||
|
||||
zone,key := attr.ParseZone(key)
|
||||
zone, key := attr.ParseZone(key)
|
||||
if zone != attr.UnknownZone {
|
||||
// TODO: We only allow Locally scoped attributes to be set here.
|
||||
// To set a publicly scoped zone you need to write a dedicated handler/functionality
|
||||
|
|
|
@ -85,10 +85,9 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
|||
}
|
||||
|
||||
// CwtchPeer will always set this now...
|
||||
tag,_ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants.Tag)
|
||||
tag, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants.Tag)
|
||||
e.Data[constants.Tag] = tag
|
||||
|
||||
|
||||
if e.Data[event.Created] == event.True {
|
||||
name, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants.Name)
|
||||
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name, name)
|
||||
|
@ -116,12 +115,12 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
|||
}
|
||||
}
|
||||
|
||||
nick, exists := profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name)
|
||||
nick, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants.Name)
|
||||
if !exists {
|
||||
nick = onion
|
||||
}
|
||||
|
||||
picVal, ok := profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants2.Picture)
|
||||
picVal, ok := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.Picture)
|
||||
if !ok {
|
||||
picVal = ImageToString(NewImage(RandomProfileImage(onion), TypeImageDistro))
|
||||
}
|
||||
|
@ -131,6 +130,10 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
|||
}
|
||||
picPath := GetPicturePath(pic)
|
||||
|
||||
// Set publicly scopes attributes
|
||||
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name, nick)
|
||||
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants2.Picture, picPath)
|
||||
|
||||
online, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline)
|
||||
|
||||
e.Data[constants.Name] = nick
|
||||
|
|
Loading…
Reference in New Issue