From 1dfe265ad2fc8c166c27aabf924d581ac5be81af Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 5 Jan 2017 16:18:14 +0000 Subject: [PATCH] presence: allow control of subscription deletion use the configuration xavp to control subscription deletion after notify searches for `delete_subscription` value in the configuration xavp --- src/modules/presence/notify.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/modules/presence/notify.c b/src/modules/presence/notify.c index aaa4b51abd7..c1636c7d38b 100644 --- a/src/modules/presence/notify.c +++ b/src/modules/presence/notify.c @@ -1818,6 +1818,23 @@ void run_notify_reply_event(struct cell *t, struct tmcb_params *ps) } +int pres_get_delete_sub(void) +{ + sr_xavp_t *vavp = NULL; + str vname = str_init("delete_subscription"); + + if(pres_xavp_cfg.s==NULL || pres_xavp_cfg.len<=0) { + return 0; + } + + vavp = xavp_get_child_with_ival(&pres_xavp_cfg, &vname); + if(vavp!=NULL) { + return (int)vavp->val.v.i; + } + + return 0; +} + void p_tm_callback( struct cell *t, int type, struct tmcb_params *ps) { subs_t* subs; @@ -1835,7 +1852,10 @@ void p_tm_callback( struct cell *t, int type, struct tmcb_params *ps) run_notify_reply_event(t, ps); - if(ps->code == 404 || ps->code == 481 || (ps->code == 408 && timeout_rm_subs)) { + if(ps->code == 404 + || ps->code == 481 + || (ps->code == 408 && timeout_rm_subs) + || pres_get_delete_sub()) { delete_subs(&subs->pres_uri, &subs->event->name, &subs->to_tag, &subs->from_tag, &subs->callid); }