瀏覽代碼

modules_k/presence: Added additional return value to pres_auth_status() for polite-block

- pres_auth_status() currently returns just the status of presence relationship.
- However, polite-block consists of a combination of status and reason,
  a polite-blocked watcher has ACTIVE status but a reason of polite-block.
  This means that even though blocked, when just checking based on status,
  polite-blocked watchers appear to be authorised.
- After this change pres_auth_status() returns a magic value of 5 when
  a watcher is polite-blocked.
- Feature added by Hugh Waite @ Crocodile RCS.
pd 13 年之前
父節點
當前提交
27ab10b4c6
共有 2 個文件被更改,包括 5 次插入0 次删除
  1. 2 0
      modules_k/presence/presence.c
  2. 3 0
      modules_k/presence/subscribe.h

+ 2 - 0
modules_k/presence/presence.c

@@ -1465,6 +1465,8 @@ int pres_auth_status(struct sip_msg* msg, str watcher_uri, str presentity_uri)
 	   subs.status);
     pkg_free(rules_doc->s);
     pkg_free(rules_doc);
+    if ((subs.reason.len == 12) && (strncmp(subs.reason.s, "polite-block", 12) == 0))
+		return POLITE_BLOCK_STATUS;
     return subs.status;
 
  err:

+ 3 - 0
modules_k/presence/subscribe.h

@@ -46,6 +46,9 @@ struct pres_ev;
 #define PENDING_STATUS       2
 #define TERMINATED_STATUS    3
 #define WAITING_STATUS       4
+/* Additional value returned from pres_auth_status when the status is ACTIVE
+   and reason is polite-block */
+#define POLITE_BLOCK_STATUS  5
 
 #define INTERNAL_UPDATE_FALSE	0
 #define INTERNAL_UPDATE_TRUE	1