Mercurial > prosody-modules
annotate mod_watch_spam_reports/mod_watch_spam_reports.lua @ 5869:faf1f1c833e8
mod_pubsub_serverinfo: update reference to XEP.
author | Guus der Kinderen <guus.der.kinderen@gmail.com> |
---|---|
date | Thu, 14 Mar 2024 09:55:46 +0100 |
parents | 97d34d520cfa |
children |
rev | line source |
---|---|
4051
91e2e510e17c
mod_watch_spam_reports: Show reporters bare JID instead of full JID
Martin Dosch <martin@mdosch.de>
parents:
4046
diff
changeset
|
1 local jid = require "util.jid"; |
4663
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
2 local set = require "util.set"; |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
3 local st = require "util.stanza"; |
4663
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
4 local usermanager = require "core.usermanager"; |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
5 local host = module.host; |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
6 |
4663
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
7 local admins; |
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
8 if usermanager.get_jids_with_role then |
5022
97d34d520cfa
mod_watch_spam_reports: Fix traceback due to misplaced parenthesis (thanks Menel)
Kim Alvefur <zash@zash.se>
parents:
4663
diff
changeset
|
9 admins = set.new(usermanager.get_jids_with_role("prosody:admin", host)); |
4663
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
10 else -- COMPAT w/pre-0.12 |
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
11 admins = module:get_option_inherited_set("admins"); |
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
12 end |
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
13 |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
14 module:depends("spam_reporting") |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
15 |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
16 module:hook("spam_reporting/spam-report", function(event) |
4061
9745a623c7ed
mod_watch_spam_reports: Define variable prior to using it
Martin Dosch <martin@mdosch.de>
parents:
4054
diff
changeset
|
17 local reporter_bare_jid = jid.bare(event.stanza.attr.from) |
4657
78ef5d9e2361
mod_watch_spam_reports: Prepare for changing 'reason' to an optional value
Kim Alvefur <zash@zash.se>
parents:
4611
diff
changeset
|
18 local report = reporter_bare_jid.." reported spam from "..event.jid..": "..(event.reason or "no reason given") |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
19 for admin_jid in admins |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
20 do |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
21 module:send(st.message({from=host, |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
22 type="chat",to=admin_jid}, |
4061
9745a623c7ed
mod_watch_spam_reports: Define variable prior to using it
Martin Dosch <martin@mdosch.de>
parents:
4054
diff
changeset
|
23 report)); |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
24 end |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
25 end) |
4611
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
26 |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
27 module:hook("spam_reporting/abuse-report", function(event) |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
28 local reporter_bare_jid = jid.bare(event.stanza.attr.from) |
4657
78ef5d9e2361
mod_watch_spam_reports: Prepare for changing 'reason' to an optional value
Kim Alvefur <zash@zash.se>
parents:
4611
diff
changeset
|
29 local report = reporter_bare_jid.." reported abuse from "..event.jid..": "..(event.reason or "no reason given") |
4611
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
30 for admin_jid in admins |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
31 do |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
32 module:send(st.message({from=host, |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
33 type="chat",to=admin_jid}, |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
34 report)); |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
35 end |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
36 end) |