From c18844a0d51fa6d069f11785e1fc1379ae9b005a Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 17 Mar 2021 15:39:44 -0700 Subject: [PATCH] Save Peer History Settings --- utils/contacts.go | 1 + utils/eventHandler.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/contacts.go b/utils/contacts.go index d9f6176..13e721c 100644 --- a/utils/contacts.go +++ b/utils/contacts.go @@ -6,4 +6,5 @@ type Contact struct { Status string `json:"status"` Picture string `json:"picture"` Authorization string `json:"authorization"` + SaveHistory string `json:"saveConversationHistory"` } diff --git a/utils/eventHandler.go b/utils/eventHandler.go index 4670be0..0f9b70d 100644 --- a/utils/eventHandler.go +++ b/utils/eventHandler.go @@ -107,7 +107,11 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string { cpicPath := GetPicturePath(cpic) contactInfo := profile.GetContact(contact) name, _ := contactInfo.GetAttribute(attr.GetLocalScope(constants.Name)) - contacts = append(contacts, Contact{Name: name, Onion: contactInfo.Onion, Status: contactInfo.State, Picture: cpicPath, Authorization: string(contactInfo.Authorization)}) + saveHistory, set := contactInfo.GetAttribute(event.SaveHistoryKey) + if !set { + saveHistory = event.DeleteHistoryDefault + } + contacts = append(contacts, Contact{Name: name, Onion: contactInfo.Onion, Status: contactInfo.State, Picture: cpicPath, Authorization: string(contactInfo.Authorization), SaveHistory: saveHistory}) } bytes, _ := json.Marshal(contacts)