From aa54759337ce27b5af1e850be06191d24bfa61d3 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 5 Oct 2019 18:22:14 +0100 Subject: [PATCH] Additional error checking on user record deletion --- modules/userinfo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/userinfo.py b/modules/userinfo.py index e4035e8..e5cc764 100644 --- a/modules/userinfo.py +++ b/modules/userinfo.py @@ -108,14 +108,17 @@ def addUser(name, channel, nick, user): p.sadd(chanspace, channel) p.execute() -def delUser(name, channel, nick, user): +def delUser(name, channel, nick, user): gnamespace, namespace, chanspace = getNamespace(name, channel, nick) p = main.r.pipeline() channels = main.r.smembers(chanspace) p.srem(namespace, nick) if channels == {channel.encode()}: p.delete(chanspace) - p.srem(gnamespace, user) + if user: + p.srem(gnamespace, user) + else: + warn("Attempt to delete nonexistent user: %s" % user) else: p.srem(chanspace, channel) p.execute()