unblock contact endpoint
This commit is contained in:
parent
a7b0c6c933
commit
f04e5c741c
|
@ -204,7 +204,7 @@ func (m *Messenger) GetContactByID(pubKey string) *Contact {
|
|||
return contact
|
||||
}
|
||||
|
||||
func (m *Messenger) SetLocalNickname(pubKey string, nickname string) (*MessengerResponse, error) {
|
||||
func (m *Messenger) SetContactLocalNickname(pubKey string, nickname string) (*MessengerResponse, error) {
|
||||
|
||||
contact, ok := m.allContacts.Load(pubKey)
|
||||
if !ok {
|
||||
|
@ -255,6 +255,31 @@ func (m *Messenger) BlockContact(contact *Contact) ([]*Chat, error) {
|
|||
return chats, nil
|
||||
}
|
||||
|
||||
func (m *Messenger) UnblockContact(contactID string) error {
|
||||
contact, ok := m.allContacts.Load(contactID)
|
||||
if !ok || !contact.Added {
|
||||
return nil
|
||||
}
|
||||
|
||||
contact.Unblock()
|
||||
contact.LastUpdatedLocally = m.getTimesource().GetCurrentTime()
|
||||
|
||||
m.allContacts.Store(contact.ID, contact)
|
||||
|
||||
err := m.syncContact(context.Background(), contact)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// re-register for push notifications
|
||||
err = m.reregisterForPushNotifications()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Send contact updates to all contacts added by us
|
||||
func (m *Messenger) SendContactUpdates(ctx context.Context, ensName, profileImage string) (err error) {
|
||||
myID := contactIDFromPublicKey(&m.identity.PublicKey)
|
||||
|
|
|
@ -147,7 +147,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallation() {
|
|||
contact.LocalNickname = "Test Nickname"
|
||||
_, err = s.m.AddContact(context.Background(), contact.ID)
|
||||
s.Require().NoError(err)
|
||||
_, err = s.m.SetLocalNickname(contact.ID, contact.LocalNickname)
|
||||
_, err = s.m.SetContactLocalNickname(contact.ID, contact.LocalNickname)
|
||||
s.Require().NoError(err)
|
||||
|
||||
// add chat
|
||||
|
|
|
@ -298,6 +298,10 @@ func (api *PublicAPI) BlockContact(parent context.Context, contact *protocol.Con
|
|||
return api.service.messenger.BlockContact(contact)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) UnblockContact(parent context.Context, contactID string) error {
|
||||
return api.service.messenger.UnblockContact(contactID)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) Contacts(parent context.Context) []*protocol.Contact {
|
||||
return api.service.messenger.Contacts()
|
||||
}
|
||||
|
@ -592,6 +596,10 @@ func (api *PublicAPI) RemoveContact(ctx context.Context, pubKey string) (*protoc
|
|||
return api.service.messenger.RemoveContact(ctx, pubKey)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) SetContactLocalNickname(ctx context.Context, pubKey, nickname string) (*protocol.MessengerResponse, error) {
|
||||
return api.service.messenger.SetContactLocalNickname(pubKey, nickname)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) ClearHistory(request *requests.ClearHistory) (*protocol.MessengerResponse, error) {
|
||||
return api.service.messenger.ClearHistory(request)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue