Republish image on change of visibility settings
This commit is contained in:
parent
4e33e46795
commit
75aebd94ab
|
@ -1002,13 +1002,9 @@ func (m *Messenger) watchIdentityImageChanges() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-channel:
|
case <-channel:
|
||||||
if m.online() {
|
err := m.PublishIdentityImage()
|
||||||
if err := m.publishContactCode(); err != nil {
|
if err != nil {
|
||||||
m.logger.Error("failed to publish contact code", zap.Error(err))
|
m.logger.Error("failed to publish identity image", zap.Error(err))
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
m.shouldPublishContactCode = true
|
|
||||||
}
|
}
|
||||||
case <-m.quit:
|
case <-m.quit:
|
||||||
return
|
return
|
||||||
|
@ -1017,6 +1013,23 @@ func (m *Messenger) watchIdentityImageChanges() {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Messenger) PublishIdentityImage() error {
|
||||||
|
// Reset last published time for ChatIdentity so new contact can receive data
|
||||||
|
err := m.resetLastPublishedTimeForChatIdentity()
|
||||||
|
if err != nil {
|
||||||
|
m.logger.Error("failed to reset publish time", zap.Error(err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not online, we schedule it
|
||||||
|
if !m.online() {
|
||||||
|
m.shouldPublishContactCode = true
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.publishContactCode()
|
||||||
|
}
|
||||||
|
|
||||||
// handlePushNotificationClientRegistration handles registration events
|
// handlePushNotificationClientRegistration handles registration events
|
||||||
func (m *Messenger) handlePushNotificationClientRegistrations(c chan struct{}) {
|
func (m *Messenger) handlePushNotificationClientRegistrations(c chan struct{}) {
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"go.uber.org/zap"
|
|
||||||
|
|
||||||
"github.com/status-im/status-go/protocol/common"
|
"github.com/status-im/status-go/protocol/common"
|
||||||
"github.com/status-im/status-go/protocol/protobuf"
|
"github.com/status-im/status-go/protocol/protobuf"
|
||||||
|
@ -51,11 +50,8 @@ func (m *Messenger) AddContact(ctx context.Context, pubKey string) (*MessengerRe
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset last published time for ChatIdentity so new contact can receive data
|
// Reset last published time for ChatIdentity so new contact can receive data
|
||||||
contactCodeTopic := transport.ContactCodeTopic(&m.identity.PublicKey)
|
err = m.resetLastPublishedTimeForChatIdentity()
|
||||||
m.logger.Debug("contact state changed ResetWhenChatIdentityLastPublished")
|
|
||||||
err = m.persistence.ResetWhenChatIdentityLastPublished(contactCodeTopic)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.logger.Error("ResetWhenChatIdentityLastPublished error", zap.Error(err))
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +92,13 @@ func (m *Messenger) AddContact(ctx context.Context, pubKey string) (*MessengerRe
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Messenger) resetLastPublishedTimeForChatIdentity() error {
|
||||||
|
// Reset last published time for ChatIdentity so new contact can receive data
|
||||||
|
contactCodeTopic := transport.ContactCodeTopic(&m.identity.PublicKey)
|
||||||
|
m.logger.Debug("contact state changed ResetWhenChatIdentityLastPublished")
|
||||||
|
return m.persistence.ResetWhenChatIdentityLastPublished(contactCodeTopic)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Messenger) removeContact(ctx context.Context, response *MessengerResponse, pubKey string) error {
|
func (m *Messenger) removeContact(ctx context.Context, response *MessengerResponse, pubKey string) error {
|
||||||
contact, ok := m.allContacts.Load(pubKey)
|
contact, ok := m.allContacts.Load(pubKey)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -233,16 +236,12 @@ func (m *Messenger) saveContact(contact *Contact) error {
|
||||||
|
|
||||||
// Reregister only when data has changed
|
// Reregister only when data has changed
|
||||||
if shouldReregisterForPushNotifications {
|
if shouldReregisterForPushNotifications {
|
||||||
// Reset last published time for ChatIdentity so new contact can receive data
|
err := m.resetLastPublishedTimeForChatIdentity()
|
||||||
contactCodeTopic := transport.ContactCodeTopic(&m.identity.PublicKey)
|
|
||||||
m.logger.Debug("contact state changed ResetWhenChatIdentityLastPublished")
|
|
||||||
err = m.persistence.ResetWhenChatIdentityLastPublished(contactCodeTopic)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.logger.Error("ResetWhenChatIdentityLastPublished error", zap.Error(err))
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Publish contact code
|
// Publish contact code
|
||||||
err := m.publishContactCode()
|
err = m.publishContactCode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/status-im/status-go/eth-node/crypto"
|
"github.com/status-im/status-go/eth-node/crypto"
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
"github.com/status-im/status-go/mailserver"
|
"github.com/status-im/status-go/mailserver"
|
||||||
|
"github.com/status-im/status-go/multiaccounts/accounts"
|
||||||
"github.com/status-im/status-go/protocol"
|
"github.com/status-im/status-go/protocol"
|
||||||
"github.com/status-im/status-go/protocol/common"
|
"github.com/status-im/status-go/protocol/common"
|
||||||
"github.com/status-im/status-go/protocol/communities"
|
"github.com/status-im/status-go/protocol/communities"
|
||||||
|
@ -928,6 +929,15 @@ func (api *PublicAPI) Peers() map[string][]string {
|
||||||
return api.service.messenger.Peers()
|
return api.service.messenger.Peers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *PublicAPI) ChangeIdentityImageShowTo(showTo accounts.ProfilePicturesShowToType) error {
|
||||||
|
err := api.service.accountsDB.SaveSetting("profile-pictures-show-to", showTo)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.service.messenger.PublishIdentityImage()
|
||||||
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// HELPER
|
// HELPER
|
||||||
// -----
|
// -----
|
||||||
|
|
Loading…
Reference in New Issue