]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core, mod_verto] add visibility filter to verto
authorAnthony Minessale <anthm@signalwire.com>
Tue, 25 Aug 2020 23:51:38 +0000 (23:51 +0000)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 19:01:01 +0000 (22:01 +0300)
src/mod/endpoints/mod_verto/mod_verto.c
src/switch_event.c

index 505b9892ee93e7f69b5e5c785838f1a71650d02c..e5b46da344ed536f9de62bf11c3e64e1bb204ca8 100644 (file)
@@ -672,8 +672,24 @@ static void write_event(const char *event_channel, jsock_t *use_jsock, cJSON *ev
 
                for(np = head->node; np; np = np->next) {
                        cJSON *msg = NULL, *params;
-
+                       
                        if (!use_jsock || use_jsock == np->jsock) {
+                               const char *visibility;
+                               //char *tmp;
+                               
+                               if ((visibility = cJSON_GetObjectCstr(event, "contentVisibility"))) {
+                                       if (strcasecmp(visibility, "public") &&
+                                               ((use_jsock && use_jsock->id && !strncasecmp(use_jsock->id, "guest", 5)) ||
+                                                (np->jsock->id && !strncasecmp(np->jsock->id, "guest", 5)))) {
+
+                                               continue;
+                                       }
+                               }
+                               //tmp = cJSON_Print(event);
+                               //printf("%s\n", tmp);
+                               //free(tmp);
+
+                               
                                params = cJSON_Duplicate(event, 1);
                                cJSON_AddItemToObject(params, "eventSerno", cJSON_CreateNumber(np->serno++));
                                cJSON_AddItemToObject(params, "subscribedChannel", cJSON_CreateString(head->event_channel));
index 0a0e4b3c6c1f1f1cb97ec1180ca4ff2909d7ff0a..3e5b05ae32b2efa282c57380a3fd851019e46995 100644 (file)
@@ -3608,7 +3608,8 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_add(switch_live_array_t *la, c
        switch_status_t status = SWITCH_STATUS_SUCCESS;
        const char *action = "add";
        cJSON *msg = NULL, *data = NULL;
-
+       const char *visibility = NULL;
+       
        switch_mutex_lock(la->mutex);
 
        if ((node = switch_core_hash_find(la->hash, name))) {
@@ -3675,7 +3676,9 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_add(switch_live_array_t *la, c
 
        msg = cJSON_CreateObject();
        data = json_add_child_obj(msg, "data", NULL);
-
+       if ((visibility = cJSON_GetObjectCstr(node->obj, "contentVisibility"))) {
+               cJSON_AddItemToObject(msg, "contentVisibility", cJSON_CreateString(visibility));
+       }
        cJSON_AddItemToObject(msg, "eventChannel", cJSON_CreateString(la->event_channel));
        cJSON_AddItemToObject(data, "action", cJSON_CreateString(action));