From 27d24ecaf4dcabad9ad7c76b6c78441a40dc1f32 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Mon, 23 Jul 2018 00:50:53 +0300 Subject: [PATCH] group - privacy state added --- toxygen/contacts/group_chat.py | 12 +++++++++++- toxygen/contacts/group_factory.py | 4 +++- toxygen/middleware/callbacks.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/toxygen/contacts/group_chat.py b/toxygen/contacts/group_chat.py index 5409a26..38ab686 100644 --- a/toxygen/contacts/group_chat.py +++ b/toxygen/contacts/group_chat.py @@ -8,9 +8,10 @@ from common.tox_save import ToxSave class GroupChat(contact.Contact, ToxSave): - def __init__(self, tox, profile_manager, message_getter, number, name, status_message, widget, tox_id): + def __init__(self, tox, profile_manager, message_getter, number, name, status_message, widget, tox_id, is_private): super().__init__(profile_manager, message_getter, number, name, status_message, widget, tox_id) ToxSave.__init__(self, tox) + self._is_private = is_private self._peers = [] self._add_self_to_gc() @@ -24,6 +25,15 @@ class GroupChat(contact.Contact, ToxSave): def get_context_menu_generator(self): return GroupMenuGenerator(self) + # ----------------------------------------------------------------------------------------------------------------- + # Properties + # ----------------------------------------------------------------------------------------------------------------- + + def get_is_private(self): + return self._is_private + + is_private = property(get_is_private) + # ----------------------------------------------------------------------------------------------------------------- # Peers methods # ----------------------------------------------------------------------------------------------------------------- diff --git a/toxygen/contacts/group_factory.py b/toxygen/contacts/group_factory.py index 8db3e9a..2a925f3 100644 --- a/toxygen/contacts/group_factory.py +++ b/toxygen/contacts/group_factory.py @@ -1,5 +1,6 @@ from contacts.group_chat import GroupChat from common.tox_save import ToxSave +import wrapper.toxcore_enums_and_consts as constants class GroupFactory(ToxSave): @@ -27,8 +28,9 @@ class GroupFactory(ToxSave): name = alias or self._tox.group_get_name(group_number) or tox_id status_message = self._tox.group_get_topic(group_number) message_getter = self._db.messages_getter(tox_id) + is_private = self._tox.group_get_privacy_state() == constants.TOX_GROUP_PRIVACY_STATE['PRIVATE'] group = GroupChat(self._tox, self._profile_manager, message_getter, group_number, name, status_message, - item, tox_id) + item, tox_id, is_private) group.set_alias(alias) return group diff --git a/toxygen/middleware/callbacks.py b/toxygen/middleware/callbacks.py index a480223..3d40cc9 100644 --- a/toxygen/middleware/callbacks.py +++ b/toxygen/middleware/callbacks.py @@ -489,7 +489,7 @@ def group_moderation(groups_service, contacts_provider, contacts_manager, messen elif event_type == TOX_GROUP_MOD_EVENT['MODERATOR']: update_peer_role(group, mod_peer_id, peer_id, TOX_GROUP_ROLE['MODERATOR']) - groups_service.generate_peers_list() + invoke_in_main_thread(groups_service.generate_peers_list) return wrapped