mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-26 20:48:21 +00:00
[mod_verto] check permissions on the more specific event channel for guest users to allow them to subscribe to global events but still get send/don't send permission control on specific conferences
This commit is contained in:
parent
7ad249974e
commit
f540bbbbe3
@ -663,7 +663,7 @@ static switch_status_t jsock_queue_event(jsock_t *jsock, cJSON **json, switch_bo
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_event(const char *event_channel, jsock_t *use_jsock, cJSON *event)
|
static void write_event(const char *event_channel, const char *super_channel, jsock_t *use_jsock, cJSON *event)
|
||||||
{
|
{
|
||||||
jsock_sub_node_head_t *head;
|
jsock_sub_node_head_t *head;
|
||||||
|
|
||||||
@ -678,11 +678,16 @@ static void write_event(const char *event_channel, jsock_t *use_jsock, cJSON *ev
|
|||||||
//char *tmp;
|
//char *tmp;
|
||||||
|
|
||||||
if ((visibility = cJSON_GetObjectCstr(event, "contentVisibility"))) {
|
if ((visibility = cJSON_GetObjectCstr(event, "contentVisibility"))) {
|
||||||
if (strcasecmp(visibility, "public") &&
|
if (strcasecmp(visibility, "public") && (np->jsock->id && !strncasecmp(np->jsock->id, "guest", 5))) {
|
||||||
((use_jsock && use_jsock->id && !strncasecmp(use_jsock->id, "guest", 5)) ||
|
int perm = 0;
|
||||||
(np->jsock->id && !strncasecmp(np->jsock->id, "guest", 5)))) {
|
|
||||||
|
|
||||||
if (!switch_event_channel_permission_verify(np->jsock->uuid_str, event_channel)) {
|
perm = switch_event_channel_permission_verify(np->jsock->uuid_str, event_channel);
|
||||||
|
|
||||||
|
if (!perm && super_channel) {
|
||||||
|
perm = switch_event_channel_permission_verify(np->jsock->uuid_str, super_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!perm) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -691,7 +696,6 @@ static void write_event(const char *event_channel, jsock_t *use_jsock, cJSON *ev
|
|||||||
//printf("%s\n", tmp);
|
//printf("%s\n", tmp);
|
||||||
//free(tmp);
|
//free(tmp);
|
||||||
|
|
||||||
|
|
||||||
params = cJSON_Duplicate(event, 1);
|
params = cJSON_Duplicate(event, 1);
|
||||||
cJSON_AddItemToObject(params, "eventSerno", cJSON_CreateNumber(np->serno++));
|
cJSON_AddItemToObject(params, "eventSerno", cJSON_CreateNumber(np->serno++));
|
||||||
cJSON_AddItemToObject(params, "subscribedChannel", cJSON_CreateString(head->event_channel));
|
cJSON_AddItemToObject(params, "subscribedChannel", cJSON_CreateString(head->event_channel));
|
||||||
@ -744,14 +748,14 @@ static void jsock_send_event(cJSON *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch_thread_rwlock_rdlock(verto_globals.event_channel_rwlock);
|
switch_thread_rwlock_rdlock(verto_globals.event_channel_rwlock);
|
||||||
write_event(event_channel, use_jsock, event);
|
write_event(event_channel, NULL, use_jsock, event);
|
||||||
if (strchr(event_channel, '.')) {
|
if (strchr(event_channel, '.')) {
|
||||||
char *main_channel = strdup(event_channel);
|
char *main_channel = strdup(event_channel);
|
||||||
char *p;
|
char *p;
|
||||||
switch_assert(main_channel);
|
switch_assert(main_channel);
|
||||||
p = strchr(main_channel, '.');
|
p = strchr(main_channel, '.');
|
||||||
if (p) *p = '\0';
|
if (p) *p = '\0';
|
||||||
write_event(main_channel, use_jsock, event);
|
write_event(main_channel, event_channel, use_jsock, event);
|
||||||
free(main_channel);
|
free(main_channel);
|
||||||
}
|
}
|
||||||
switch_thread_rwlock_unlock(verto_globals.event_channel_rwlock);
|
switch_thread_rwlock_unlock(verto_globals.event_channel_rwlock);
|
||||||
@ -4331,7 +4335,7 @@ static switch_bool_t verto__broadcast_func(const char *method, cJSON *params, js
|
|||||||
broadcast = cJSON_GetObjectItem(params, "localBroadcast");
|
broadcast = cJSON_GetObjectItem(params, "localBroadcast");
|
||||||
|
|
||||||
if (broadcast && broadcast->type == cJSON_True) {
|
if (broadcast && broadcast->type == cJSON_True) {
|
||||||
write_event(event_channel, NULL, jevent);
|
write_event(event_channel, NULL, NULL, jevent);
|
||||||
} else {
|
} else {
|
||||||
switch_event_channel_broadcast(event_channel, &jevent, modname, verto_globals.event_channel_id);
|
switch_event_channel_broadcast(event_channel, &jevent, modname, verto_globals.event_channel_id);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user