summaryrefslogtreecommitdiff
path: root/mod_stanza_delay.lua
blob: f07ad12dcaa52ede701f2526b5f64bc63151fac3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- SPDX-FileCopyrightText: 2026 Matthew Fennell <matthew@fennell.dev>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later

-- This plugin delays IQs from any user named "user1" for 45 seconds.
-- This is useful when testing Monal's MLPromises. By delaying the response for
-- longer than the time an iOS app lives in the background, we can check what
-- happens when a promise is handled by the notification service.

function on_message(event)
	local username = event.stanza:find"{jabber:iq:register}query/username#"
	if (username == "user1") then
		module:log("info", "Sleeping to give time to swipe away Monal");
		os.execute("sleep 45")
		module:log("info", "Done sleeping");
	end
end

module:hook("iq/host", on_message, 9999);