Skip to content

Commit

Permalink
presence_xml: use parameter presence/default_expires instead of 3600 …
Browse files Browse the repository at this point in the history
…constant

- GH #2996
  • Loading branch information
Adrian Tabacioiu committed Jan 14, 2022
1 parent 9a1dfe7 commit 57927a2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/modules/presence_xml/add_events.c
Expand Up @@ -33,6 +33,8 @@
#include "../../core/parser/parse_content.h"
#include "../../core/data_lump_rpl.h"
#include "../../core/ut.h"
#include "../../core/sr_module.h"
#include "../presence/presence.h"
#include "xcap_auth.h"
#include "notify_body.h"
#include "add_events.h"
Expand All @@ -49,6 +51,15 @@ int xml_add_events(void)
{
pres_ev_t event;

/* read default expires from presence, if exists */
int pres_default_expires = 3600;
modparam_t type = 0;
int *param = find_param_export(find_module_by_name("presence"), "default_expires", INT_PARAM, &type);
if ( param && (type == INT_PARAM) )
pres_default_expires = *param;
else
LOG(L_WARN, "cannot find pres_default_expires parameter or type is not correct in the presence module\n");

if(!pxml_disable_presence) {
/* constructing presence event */
memset(&event, 0, sizeof(pres_ev_t));
Expand All @@ -65,7 +76,7 @@ int xml_add_events(void)
event.agg_nbody = pres_agg_nbody;
event.evs_publ_handl = xml_publ_handl;
event.free_body = free_xml_body;
event.default_expires = 3600;
event.default_expires = pres_default_expires;
event.get_rules_doc = pres_get_rules_doc;
event.get_pidf_doc = pres_get_pidf_doc;
if(psapi.add_event(&event) < 0) {
Expand All @@ -85,7 +96,7 @@ int xml_add_events(void)
event.content_type.len = 27;
event.type = WINFO_TYPE;
event.free_body = free_xml_body;
event.default_expires = 3600;
event.default_expires = pres_default_expires;

if(psapi.add_event(&event) < 0) {
LM_ERR("while adding event presence.winfo\n");
Expand All @@ -106,7 +117,7 @@ int xml_add_events(void)
event.content_type.len = 27;
event.type = PUBL_TYPE;
event.free_body = free_xml_body;
event.default_expires = 3600;
event.default_expires = pres_default_expires;
if(psapi.add_event(&event) < 0) {
LM_ERR("while adding event dialog;sla\n");
return -1;
Expand All @@ -124,7 +135,7 @@ int xml_add_events(void)
event.content_type.len = 25;

event.type = PUBL_TYPE;
event.default_expires = 3600;
event.default_expires = pres_default_expires;
if(psapi.add_event(&event) < 0) {
LM_ERR("while adding event xcap-diff\n");
return -1;
Expand Down

0 comments on commit 57927a2

Please sign in to comment.