Use if else in prosody Event Sync


I would like to know if it is possible to pass a variable in prosday and I use if else condition

indeed I use this module event_sync and I have two apis and I will point on the apis according to a condition

do you think there is a solution

something like this :

if(condition) {
api_prefix = “x”;
api_prefix = ‘y’;

Component “” “event_sync_component”
muc_component = “
api_prefix = “http://your.api.server/api

--- The following are all optional
api_headers = {
    ["Authorization"] = "Bearer TOKEN-237958623045";
api_timeout = 10  -- timeout if API does not respond within 10s
retry_count = 5  -- retry up to 5 times
api_retry_delay = 1  -- wait 1s between retries

-- change retry rules so we also retry if endpoint returns HTTP 408
api_should_retry_for_code = function (code)
    return code >= 500 or code == 408

If you’re happy to modify the event_sync component and maintain it yourself, sure, that’s possible.

How to do it would depend on what the conditions are. Is that fixed per deployment, or determined dynamically for each event?

thanks @shawn for you replay

yes i already modified the module, it’s by event and not by server deployment but i’m felxible i can change, can you show me a simple example how i can pass a prosday module variable event_sync to the prosday config or i put the api prefix or if you have an idea


Do you mean something like this?

So here in prosody config one would set api_prefix_rooms and api_prefix_occupants within the event_sync component block, and the module would use different api prefixes for room events and occupant events.

That should hopefully give you a start to modify as you see fit.

p.s. I haven’t tested the modified script so cannot guarantee it is correct.

thanks I’ll try