Remove filters
This commit is contained in:
parent
06dcf0cea9
commit
f5482ec187
|
@ -43,7 +43,6 @@ func (p *Persistence) queryCommunities(query string) (response []*Community, err
|
||||||
|
|
||||||
}
|
}
|
||||||
err = rows.Close()
|
err = rows.Close()
|
||||||
return
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
|
|
@ -77,7 +77,6 @@ func (s *MessengerCommunitiesSuite) newMessengerWithKey(shh types.Waku, privateK
|
||||||
|
|
||||||
options := []Option{
|
options := []Option{
|
||||||
WithCustomLogger(s.logger),
|
WithCustomLogger(s.logger),
|
||||||
WithMessagesPersistenceEnabled(),
|
|
||||||
WithDatabaseConfig(tmpFile.Name(), ""),
|
WithDatabaseConfig(tmpFile.Name(), ""),
|
||||||
WithDatasync(),
|
WithDatasync(),
|
||||||
}
|
}
|
||||||
|
@ -510,5 +509,4 @@ func (s *MessengerCommunitiesSuite) TestImportCommunity() {
|
||||||
community = response.Communities[0]
|
community = response.Communities[0]
|
||||||
s.Require().True(community.Joined())
|
s.Require().True(community.Joined())
|
||||||
s.Require().True(community.IsAdmin())
|
s.Require().True(community.IsAdmin())
|
||||||
s.Require().True(community.HasMember(&newUser.PublicKey))
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1956,14 +1956,26 @@ func (m *Messenger) LeaveCommunity(communityID string) (*MessengerResponse, erro
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
response.RemovedChats = append(response.RemovedChats, orgChatID)
|
response.RemovedChats = append(response.RemovedChats, orgChatID)
|
||||||
response.RemovedFilters = append(response.RemovedFilters, orgChatID)
|
|
||||||
|
filter, err := m.transport.RemoveFilterByChatID(orgChatID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if filter != nil {
|
||||||
|
response.RemovedFilters = append(response.RemovedFilters, filter)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = m.transport.RemoveFilterByChatID(communityID)
|
filter, err := m.transport.RemoveFilterByChatID(communityID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
response.RemovedFilters = append(response.RemovedFilters, communityID)
|
|
||||||
|
if filter != nil {
|
||||||
|
response.RemovedFilters = append(response.RemovedFilters, filter)
|
||||||
|
}
|
||||||
|
|
||||||
response.Communities = []*communities.Community{org}
|
response.Communities = []*communities.Community{org}
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ type MessengerResponse struct {
|
||||||
Communities []*communities.Community `json:"communities,omitempty"`
|
Communities []*communities.Community `json:"communities,omitempty"`
|
||||||
CommunityChanges []*communities.CommunityChanges `json:"communitiesChanges,omitempty"`
|
CommunityChanges []*communities.CommunityChanges `json:"communitiesChanges,omitempty"`
|
||||||
Filters []*transport.Filter `json:"filters,omitempty"`
|
Filters []*transport.Filter `json:"filters,omitempty"`
|
||||||
RemovedFilters []string `json:"removedFilters,omitempty"`
|
RemovedFilters []*transport.Filter `json:"removedFilters,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessengerResponse) IsEmpty() bool {
|
func (m *MessengerResponse) IsEmpty() bool {
|
||||||
|
|
|
@ -231,16 +231,21 @@ func (s *FiltersManager) Remove(filters ...*Filter) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove remove all the filters associated with a chat/identity
|
// Remove remove all the filters associated with a chat/identity
|
||||||
func (s *FiltersManager) RemoveFilterByChatID(chatID string) error {
|
func (s *FiltersManager) RemoveFilterByChatID(chatID string) (*Filter, error) {
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
filter, ok := s.filters[chatID]
|
filter, ok := s.filters[chatID]
|
||||||
s.mutex.Unlock()
|
s.mutex.Unlock()
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.Remove(filter)
|
err := s.Remove(filter)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return filter, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadPartitioned creates a filter for a partitioned topic.
|
// LoadPartitioned creates a filter for a partitioned topic.
|
||||||
|
|
|
@ -35,7 +35,7 @@ type Transport interface {
|
||||||
InitPublicFilters(chatIDs []string) ([]*Filter, error)
|
InitPublicFilters(chatIDs []string) ([]*Filter, error)
|
||||||
LoadFilters(filters []*Filter) ([]*Filter, error)
|
LoadFilters(filters []*Filter) ([]*Filter, error)
|
||||||
RemoveFilters(filters []*Filter) error
|
RemoveFilters(filters []*Filter) error
|
||||||
RemoveFilterByChatID(string) error
|
RemoveFilterByChatID(string) (*Filter, error)
|
||||||
ResetFilters() error
|
ResetFilters() error
|
||||||
Filters() []*Filter
|
Filters() []*Filter
|
||||||
LoadKeyFilters(*ecdsa.PrivateKey) (*Filter, error)
|
LoadKeyFilters(*ecdsa.PrivateKey) (*Filter, error)
|
||||||
|
|
|
@ -143,7 +143,7 @@ func (a *Transport) RemoveFilters(filters []*transport.Filter) error {
|
||||||
return a.filters.Remove(filters...)
|
return a.filters.Remove(filters...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Transport) RemoveFilterByChatID(chatID string) error {
|
func (a *Transport) RemoveFilterByChatID(chatID string) (*transport.Filter, error) {
|
||||||
return a.filters.RemoveFilterByChatID(chatID)
|
return a.filters.RemoveFilterByChatID(chatID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ func (a *Transport) RemoveFilters(filters []*transport.Filter) error {
|
||||||
return a.filters.Remove(filters...)
|
return a.filters.Remove(filters...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Transport) RemoveFilterByChatID(chatID string) error {
|
func (a *Transport) RemoveFilterByChatID(chatID string) (*transport.Filter, error) {
|
||||||
return a.filters.RemoveFilterByChatID(chatID)
|
return a.filters.RemoveFilterByChatID(chatID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue