Prosody modules: fix lua 5.3/5.4 compatibility:
Lua 5.3 comes with new integers type, and can fail if floats are used where integers are wanted.
This commit is contained in:
parent
5018d04b78
commit
5566f4b6cf
@ -88,7 +88,7 @@ local function handle_broadcast_message(event)
|
||||
end
|
||||
local id = stanza.attr.id;
|
||||
if not id then
|
||||
-- message should alway have an id, but just in case...
|
||||
-- message should always have an id, but just in case...
|
||||
module:log("warn", "Message has no id, wont delay it.");
|
||||
return;
|
||||
end
|
||||
@ -106,7 +106,7 @@ local function handle_broadcast_message(event)
|
||||
if stanza.attr.from then
|
||||
local from_occupant = room:get_occupant_by_nick(stanza.attr.from);
|
||||
if from_occupant and valid_roles[from_occupant.role or "none"] < moderator_role_value then
|
||||
module:log("debug", "Message %s / %s must be sent separatly to it initialior %s.", id, stanza_id, delay, stanza.attr.from);
|
||||
module:log("debug", "Message %s / %s must be sent separatly to it initiator %s.", id, stanza_id, delay, stanza.attr.from);
|
||||
room:route_to_occupant(from_occupant, stanza);
|
||||
end
|
||||
end
|
||||
@ -114,7 +114,7 @@ local function handle_broadcast_message(event)
|
||||
-- adding a tag, so that moderators can know that this message is delayed.
|
||||
stanza:tag(moderation_delay_tag, {
|
||||
delay = "" .. delay;
|
||||
waiting = string.format("%i", get_time() + delay);
|
||||
waiting = string.format("%i", math.floor(get_time() + delay));
|
||||
}):up();
|
||||
|
||||
-- then, sending to moderators (and only moderators):
|
||||
|
@ -72,7 +72,7 @@ local function end_current_poll (room)
|
||||
end
|
||||
|
||||
local function schedule_poll_end (room_jid, timestamp)
|
||||
local delay = timestamp - get_time();
|
||||
local delay = timestamp - math.floor(get_time());
|
||||
if delay <= 0 then
|
||||
delay = 1;
|
||||
end
|
||||
@ -101,7 +101,7 @@ local function create_poll(room, fields, occupant)
|
||||
module:log("debug", "Creating a new poll for room %s, by %s", room.jid, occupant.bare_jid);
|
||||
room._data.current_poll = fields;
|
||||
room._data.current_poll.poll_id = id.short();
|
||||
room._data.current_poll.end_timestamp = get_time() + (60 * fields["muc#roompoll_duration"]);
|
||||
room._data.current_poll.end_timestamp = math.floor(get_time()) + (60 * fields["muc#roompoll_duration"]);
|
||||
room._data.current_poll.votes_by_occupant = {};
|
||||
room._data.current_poll.votes_by_choices = {};
|
||||
room._data.current_poll.choices_ordered = {}; -- choices labels with numerical index, so we can have correct order
|
||||
@ -151,7 +151,7 @@ local function handle_groupchat(event)
|
||||
|
||||
-- Ok, seems it is a vote.
|
||||
|
||||
if get_time() >= room._data.current_poll.end_timestamp then
|
||||
if math.floor(get_time()) >= room._data.current_poll.end_timestamp then
|
||||
module:log("debug", "Got a vote for a finished poll, not counting it.");
|
||||
-- Note: we keep bouncing messages a few seconds/minutes after the poll end
|
||||
-- to be sure any user that send the vote too late won't expose his choice.
|
||||
@ -222,7 +222,7 @@ local function room_restored(event)
|
||||
end
|
||||
|
||||
module:log("info", "Restoring room %s with current ongoing poll.", room.jid);
|
||||
local now = get_time();
|
||||
local now = math.floor(get_time());
|
||||
if now >= room._data.current_poll.end_timestamp then
|
||||
module:log("info", "Current poll is over for room %s, ending it", room.jid);
|
||||
end_current_poll(room);
|
||||
|
Loading…
Reference in New Issue
Block a user