Allow to leave chat without removing it

This commit is contained in:
Andrea Maria Piana 2020-04-14 13:49:03 +02:00
parent f3fc6812cd
commit 4d2fb67add
3 changed files with 7 additions and 5 deletions

View File

@ -1 +1 @@
0.52.0
0.52.1

View File

@ -1020,7 +1020,7 @@ func (m *Messenger) ConfirmJoiningGroup(ctx context.Context, chatID string) (*Me
return &response, m.saveChat(chat)
}
func (m *Messenger) LeaveGroupChat(ctx context.Context, chatID string) (*MessengerResponse, error) {
func (m *Messenger) LeaveGroupChat(ctx context.Context, chatID string, remove bool) (*MessengerResponse, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
@ -1077,7 +1077,9 @@ func (m *Messenger) LeaveGroupChat(ctx context.Context, chatID string) (*Messeng
}
chat.updateChatFromProtocolGroup(group)
chat.Active = false
if remove {
chat.Active = false
}
response.Chats = []*Chat{chat}
response.Messages = buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations)

View File

@ -202,8 +202,8 @@ func (api *PublicAPI) Leave(chat protocol.Chat) error {
return api.service.messenger.Leave(chat)
}
func (api *PublicAPI) LeaveGroupChat(ctx Context, chatID string) (*protocol.MessengerResponse, error) {
return api.service.messenger.LeaveGroupChat(ctx, chatID)
func (api *PublicAPI) LeaveGroupChat(ctx Context, chatID string, remove bool) (*protocol.MessengerResponse, error) {
return api.service.messenger.LeaveGroupChat(ctx, chatID, remove)
}
func (api *PublicAPI) CreateGroupChatWithMembers(ctx Context, name string, members []string) (*protocol.MessengerResponse, error) {