Commit e0557fda authored by Philipp Hörist's avatar Philipp Hörist

Pass only JID to bookmark module

Fixes #9754
parent 0c9cd26a
......@@ -21,6 +21,7 @@ from typing import Optional
import copy
import nbxmpp
from nbxmpp.protocol import JID
from nbxmpp.util import is_error_result
from nbxmpp.structs import BookmarkData
from nbxmpp.const import BookmarkStoreType
......@@ -129,7 +130,7 @@ class Bookmarks(BaseModule):
if not bookmark_copy.name:
# No name was given for this bookmark
# Use the first part of JID instead
name = bookmark_copy.jid.split("@")[0]
name = bookmark_copy.jid.getNode()
bookmark_copy = bookmark_copy._replace(name=name)
if short_name:
......@@ -206,7 +207,15 @@ class Bookmarks(BaseModule):
self._account, str(bookmark.jid), bookmark.nick,
bookmark.password, minimize=minimize)
def add_bookmark(self, name, jid, autojoin, password, nick):
def add_bookmark(self,
name: str,
jid: JID,
autojoin: bool,
password: str,
nick: str) -> None:
if self.is_bookmark(jid):
return
bookmark = BookmarkData(jid=jid,
name=name,
autojoin=autojoin,
......
......@@ -33,6 +33,7 @@ import logging
from enum import IntEnum, unique
import nbxmpp
from nbxmpp.protocol import JID
from nbxmpp.const import StatusCode
from nbxmpp.const import Affiliation
from nbxmpp.const import Role
......@@ -705,7 +706,7 @@ class GroupchatControl(ChatControlBase):
password = app.gc_passwords.get(self.room_jid, '')
con = app.connections[self.account]
con.get_module('Bookmarks').add_bookmark(self.name,
self.room_jid,
JID(self.room_jid),
True,
password,
self.nick)
......
......@@ -46,6 +46,7 @@ import weakref
import uuid
import nbxmpp
from nbxmpp.protocol import JID
from nbxmpp.util import is_error_result
from nbxmpp.structs import DiscoIdentity
......@@ -1740,7 +1741,7 @@ class MucBrowser(AgentBrowser):
return
con.get_module('Bookmarks').add_bookmark(room_jid.split('@')[0],
room_jid,
JID(room_jid),
False,
'',
'')
......
......@@ -17,6 +17,7 @@ from gi.repository import Gtk
from gi.repository import Gdk
import nbxmpp
from nbxmpp.protocol import JID
from nbxmpp.util import is_error_result
from nbxmpp.structs import DiscoIdentity
......@@ -267,7 +268,7 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow):
# Add as bookmark, with autojoin and not minimized
name = app.get_nick_from_jid(self.room_jid)
con.get_module('Bookmarks').add_bookmark(name,
self.room_jid,
JID(self.room_jid),
autojoin,
password,
nickname)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment