From b495cb4c5e8671bf13724a8bff2898b4ef430023 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 22 Dec 2019 22:11:31 -0800 Subject: [PATCH] classes: clean up _expandPUID Also make the logging less noisy. --- classes.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/classes.py b/classes.py index c5a6e70..b275fb9 100644 --- a/classes.py +++ b/classes.py @@ -1686,26 +1686,17 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore): uid, nick) self.call_hooks([self.sid, 'SAVE', {'target': uid}]) - def _expandPUID(self, uid): + def _expandPUID(self, entityid): """ Returns the nick or server name for the given UID/SID. This method helps support protocol modules that use PUIDs internally, as they must convert them to talk with the uplink. """ - log.debug('(%s) _expandPUID: got uid %s', self.name, uid) # TODO: stop hardcoding @ as separator - if uid and isinstance(uid, str) and '@' in uid: - if uid in self.users: - # UID exists and has a @ in it, meaning it's a PUID (orignick@counter style). - # Return this user's nick accordingly. - nick = self.users[uid].nick - log.debug('(%s) Mangling target PUID %s to nick %s', self.name, uid, nick) - return nick - elif uid in self.servers: - # Ditto for servers - sname = self.servers[uid].name - log.debug('(%s) Mangling target PSID %s to server name %s', self.name, uid, sname) - return sname - return uid # Regular UID, no change + if isinstance(entityid, str) and '@' in entityid: + name = self.get_friendly_name(entityid) + log.debug('(%s) _expandPUID: mangling pseudo ID %s to %s', self.name, entityid, name) + return name + return entityid # Regular UID/SID, no change def wrap_message(self, source, target, text): """