return out;
}
+static const char *
+htsp_dvr_config_name( access_t *perm, const char *config_name )
+{
+ dvr_config_t *cfg = NULL, *cfg2;
+ htsmsg_field_t *f;
+ const char *uuid;
+
+ lock_assert(&global_lock);
+
+ if (config_name == NULL)
+ return "";
+
+ if (perm->aa_dvrcfgs == NULL)
+ return config_uuid; /* no change */
+
+ config_uuid = config_uuid ?: "";
+ HTSMSG_FOREACH(f, perm->aa_dvrcfgs) {
+ uuid = htsmsg_field_get_str(f) ?: "";
+ if (strcmp(uuid, config_name) == 0)
+ return config_name;
+ cfg2 = dvr_config_entry_find_by_uuid(uuid);
+ if (cfg2 && strcmp(cfg2->dvr_config_name, config_name) == 0)
+ return uuid;
+ if (!cfg)
+ cfg = cfg2;
+ }
+
+ if (!cfg && perm->aa_username)
+ tvhlog(LOG_INFO, "htsp", "User '%s' has no valid dvr config in ACL, using default...", perm->aa_username);
+
+ return cfg ? idnode_uuid_as_str(&cfg->dvr_id) : NULL;
+}
+
/**
* add a Dvrentry
*/
channel_t *ch = NULL;
/* Options */
- if(!(dvr_config_name = htsmsg_get_str(in, "configName")))
- dvr_config_name = "";
+ dvr_config_name = htsp_dvr_config_name(htsmsg_get_str(in, "configName")))
if(htsmsg_get_s64(in, "startExtra", &start_extra))
start_extra = 0;
if(htsmsg_get_s64(in, "stopExtra", &stop_extra))
/* Options */
if(!(title = htsmsg_get_str(in, "title")))
return htsp_error("Invalid arguments");
- if(!(dvr_config_name = htsmsg_get_str(in, "configName")))
- dvr_config_name = "";
+ dvr_config_name = htsp_dvr_config_name(htsmsg_get_str(in, "configName")))
if(!htsmsg_get_u32(in, "channelId", &u32))
ch = channel_find_by_id(u32);
if(htsmsg_get_u32(in, "maxDuration", &max_duration))