Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 6064:c4a3222165c4
mod_admin_telnet: muc:*: Fix nil index error when a room JID is passed with a non-existent host
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 05 Apr 2014 15:05:40 +0100 |
parent | 6016:eb05360e8525 |
child | 6067:dab7ad6fa23c |
child | 6311:f44876548487 |
comparison
equal
deleted
inserted
replaced
6053:2f93a04564b2 | 6064:c4a3222165c4 |
---|---|
940 return room_name, host; | 940 return room_name, host; |
941 end | 941 end |
942 | 942 |
943 function def_env.muc:create(room_jid) | 943 function def_env.muc:create(room_jid) |
944 local room, host = check_muc(room_jid); | 944 local room, host = check_muc(room_jid); |
945 if not room_name then | |
946 return room_name, host; | |
947 end | |
945 if not room then return nil, host end | 948 if not room then return nil, host end |
946 if hosts[host].modules.muc.rooms[room_jid] then return nil, "Room exists already" end | 949 if hosts[host].modules.muc.rooms[room_jid] then return nil, "Room exists already" end |
947 return hosts[host].modules.muc.create_room(room_jid); | 950 return hosts[host].modules.muc.create_room(room_jid); |
948 end | 951 end |
949 | 952 |
950 function def_env.muc:room(room_jid) | 953 function def_env.muc:room(room_jid) |
951 local room_name, host = check_muc(room_jid); | 954 local room_name, host = check_muc(room_jid); |
955 if not room_name then | |
956 return room_name, host; | |
957 end | |
952 local room_obj = hosts[host].modules.muc.rooms[room_jid]; | 958 local room_obj = hosts[host].modules.muc.rooms[room_jid]; |
953 if not room_obj then | 959 if not room_obj then |
954 return nil, "No such room: "..room_jid; | 960 return nil, "No such room: "..room_jid; |
955 end | 961 end |
956 return setmetatable({ room = room_obj }, console_room_mt); | 962 return setmetatable({ room = room_obj }, console_room_mt); |