#1393 mod_message_logging: limit message logging to a list of accounts

Reporter Stefan
Owner Nobody
Created
Updated
Stars ★ (1)
Tags
  • Type-Enhancement
  • Priority-Medium
  • Status-New
  1. Stefan on

    Description of feature: mod_message_logging: Adding an option to limit message logging to a list of accounts. Motivation: (Why?) When mod_message_logging is used it is not always intended to log all user messages. This works for me (0.11.2): --- mod_message_logging.lua.orig +++ mod_message_logging.lua @@ -5,6 +5,8 @@ local jid_split = require "util.jid".split; local stat, mkdir = require "lfs".attributes, require "lfs".mkdir; +local message_logging_users = module:get_option_set("message_logging_users", {"all"}); + -- Get a filesystem-safe string local function fsencode_char(c) return ("%%%02x"):format(c:byte()); @@ -66,10 +68,13 @@ local function handle_incoming_message(event) if message_type == "error" then return; end local from, to = jid_bare(stanza.attr.from), jid_bare(stanza.attr.to or stanza.attr.from); - if message_type == "groupchat" then - from = from.." <"..(select(3, jid_split(stanza.attr.from)) or "")..">"; + + if message_logging_users:contains(to) or message_logging_users:contains("all") then + if message_type == "groupchat" then + from = from.." <"..(select(3, jid_split(stanza.attr.from)) or "")..">"; + end + write_to_log(to, from, "RECV", stanza:get_child_text("body")); end - write_to_log(to, from, "RECV", stanza:get_child_text("body")); end local function handle_outgoing_message(event) @@ -79,7 +84,10 @@ local function handle_outgoing_message(event) if message_type == "error" then return; end local from, to = jid_bare(stanza.attr.from), jid_bare(stanza.attr.to or origin.full_jid); - write_to_log(from, to, "SEND", stanza:get_child_text("body")); + + if message_logging_users:contains(from) or message_logging_users:contains("all") then + write_to_log(from, to, "SEND", stanza:get_child_text("body")); + end end

New comment

Not published. Used for spam prevention and optional update notifications.