group topic support
This commit is contained in:
parent
820b5a0253
commit
7e08be71e0
@ -181,6 +181,9 @@ class GroupMenuGenerator(BaseContactMenuGenerator):
|
||||
menu = (builder
|
||||
.with_action(util_ui.tr('Set alias'), lambda: main_screen.set_alias(number))
|
||||
.with_submenu(copy_menu_builder)
|
||||
.with_optional_action(util_ui.tr('Set topic'),
|
||||
lambda: groups_service.set_group_topic(self._contact),
|
||||
self._contact.is_moderator_or_founder())
|
||||
.with_action(util_ui.tr('Reconnect to group'),
|
||||
lambda: groups_service.reconnect_to_group(self._contact.number))
|
||||
.with_optional_action(util_ui.tr('Disconnect from group'),
|
||||
|
@ -33,6 +33,12 @@ class GroupChat(contact.Contact, ToxSave):
|
||||
def get_self_name(self):
|
||||
return self._peers[0].name
|
||||
|
||||
def get_self_role(self):
|
||||
return self._peers[0].role
|
||||
|
||||
def is_moderator_or_founder(self):
|
||||
return self.get_self_role() <= constants.TOX_GROUP_ROLE['MODERATOR']
|
||||
|
||||
def add_peer(self, peer_id, is_current_user=False):
|
||||
peer = GroupChatPeer(peer_id,
|
||||
self._tox.group_peer_get_name(self._number, peer_id),
|
||||
|
@ -76,6 +76,17 @@ class GroupsService(tox_save.ToxSave):
|
||||
group.name = self._tox.group_get_name(group.number)
|
||||
group.status_message = self._tox.group_get_topic(group.number)
|
||||
|
||||
def set_group_topic(self, group):
|
||||
if not group.is_moderator_or_founder():
|
||||
return
|
||||
text = util_ui.tr('New topic for group {}:'.format(group.name))
|
||||
title = util_ui.tr('Set group topic')
|
||||
topic, ok = util_ui.text_dialog(text, title, group.status_message)
|
||||
if not ok or not topic:
|
||||
return
|
||||
self._tox.group_set_topic(group.number, topic)
|
||||
group.status_message = topic
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Peers list
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
@ -399,6 +399,7 @@ def group_peer_join(contacts_provider, groups_service):
|
||||
group = contacts_provider.get_group_by_number(group_number)
|
||||
group.add_peer(peer_id)
|
||||
invoke_in_main_thread(groups_service.generate_peers_list)
|
||||
invoke_in_main_thread(groups_service.update_group_info, group)
|
||||
|
||||
return wrapped
|
||||
|
||||
|
@ -1851,6 +1851,7 @@ class Tox:
|
||||
"""
|
||||
|
||||
error = c_int()
|
||||
topic = bytes(topic, 'utf-8')
|
||||
result = Tox.libtoxcore.tox_group_set_topic(self._tox_pointer, group_number, topic, len(topic), byref(error))
|
||||
return result
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user