switch to i32
This commit is contained in:
parent
818c8741f3
commit
c3b57622bb
@ -11,14 +11,14 @@ const JWT_EXPIRATION_DAYS: i64 = 7;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
|
||||
pub struct Claims {
|
||||
pub id: i64,
|
||||
pub id: i32,
|
||||
pub username: String,
|
||||
pub role: String,
|
||||
exp: i64,
|
||||
}
|
||||
|
||||
impl Claims {
|
||||
pub fn new(id: i64, username: String, role: String) -> Self {
|
||||
pub fn new(id: i32, username: String, role: String) -> Self {
|
||||
Self {
|
||||
id,
|
||||
username,
|
||||
|
@ -171,7 +171,7 @@ async fn get_user(user: web::ReqData<LoginUser>) -> Result<impl Responder, Servi
|
||||
#[put("/user/{id}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
async fn update_user(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
user: web::ReqData<LoginUser>,
|
||||
data: web::Json<User>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
@ -247,7 +247,7 @@ async fn add_user(data: web::Json<User>) -> Result<impl Responder, ServiceError>
|
||||
/// ```
|
||||
#[get("/channel/{id}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
async fn get_channel(id: web::Path<i64>) -> Result<impl Responder, ServiceError> {
|
||||
async fn get_channel(id: web::Path<i32>) -> Result<impl Responder, ServiceError> {
|
||||
if let Ok(channel) = handles::select_channel(&id).await {
|
||||
return Ok(web::Json(channel));
|
||||
}
|
||||
@ -281,7 +281,7 @@ async fn get_all_channels() -> Result<impl Responder, ServiceError> {
|
||||
#[patch("/channel/{id}")]
|
||||
#[has_any_role("Role::Admin", type = "Role")]
|
||||
async fn patch_channel(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<Channel>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
if handles::update_channel(*id, data.into_inner())
|
||||
@ -319,7 +319,7 @@ async fn add_channel(data: web::Json<Channel>) -> Result<impl Responder, Service
|
||||
/// ```
|
||||
#[delete("/channel/{id}")]
|
||||
#[has_any_role("Role::Admin", type = "Role")]
|
||||
async fn remove_channel(id: web::Path<i64>) -> Result<impl Responder, ServiceError> {
|
||||
async fn remove_channel(id: web::Path<i32>) -> Result<impl Responder, ServiceError> {
|
||||
if delete_channel(*id).await.is_ok() {
|
||||
return Ok("Delete Channel Success");
|
||||
}
|
||||
@ -339,7 +339,7 @@ async fn remove_channel(id: web::Path<i64>) -> Result<impl Responder, ServiceErr
|
||||
#[get("/playout/config/{id}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
async fn get_playout_config(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
_details: AuthDetails<Role>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
if let Ok(channel) = handles::select_channel(&id).await {
|
||||
@ -360,7 +360,7 @@ async fn get_playout_config(
|
||||
#[put("/playout/config/{id}")]
|
||||
#[has_any_role("Role::Admin", type = "Role")]
|
||||
async fn update_playout_config(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<PlayoutConfig>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
if let Ok(channel) = handles::select_channel(&id).await {
|
||||
@ -392,7 +392,7 @@ async fn update_playout_config(
|
||||
/// ```
|
||||
#[get("/presets/{id}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
async fn get_presets(id: web::Path<i64>) -> Result<impl Responder, ServiceError> {
|
||||
async fn get_presets(id: web::Path<i32>) -> Result<impl Responder, ServiceError> {
|
||||
if let Ok(presets) = handles::select_presets(*id).await {
|
||||
return Ok(web::Json(presets));
|
||||
}
|
||||
@ -411,7 +411,7 @@ async fn get_presets(id: web::Path<i64>) -> Result<impl Responder, ServiceError>
|
||||
#[put("/presets/{id}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
async fn update_preset(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<TextPreset>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
if handles::update_preset(&id, data.into_inner()).await.is_ok() {
|
||||
@ -447,7 +447,7 @@ async fn add_preset(data: web::Json<TextPreset>) -> Result<impl Responder, Servi
|
||||
/// ```
|
||||
#[delete("/presets/{id}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
async fn delete_preset(id: web::Path<i64>) -> Result<impl Responder, ServiceError> {
|
||||
async fn delete_preset(id: web::Path<i32>) -> Result<impl Responder, ServiceError> {
|
||||
if handles::delete_preset(&id).await.is_ok() {
|
||||
return Ok("Delete preset Success");
|
||||
}
|
||||
@ -475,7 +475,7 @@ async fn delete_preset(id: web::Path<i64>) -> Result<impl Responder, ServiceErro
|
||||
#[post("/control/{id}/text/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn send_text_message(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<HashMap<String, String>>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match send_message(*id, data.into_inner()).await {
|
||||
@ -497,7 +497,7 @@ pub async fn send_text_message(
|
||||
#[post("/control/{id}/playout/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn control_playout(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
control: web::Json<Process>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match control_state(*id, control.command.clone()).await {
|
||||
@ -538,7 +538,7 @@ pub async fn control_playout(
|
||||
/// ```
|
||||
#[get("/control/{id}/media/current")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn media_current(id: web::Path<i64>) -> Result<impl Responder, ServiceError> {
|
||||
pub async fn media_current(id: web::Path<i32>) -> Result<impl Responder, ServiceError> {
|
||||
match media_info(*id, "current".into()).await {
|
||||
Ok(res) => Ok(res.text().await.unwrap_or_else(|_| "Success".into())),
|
||||
Err(e) => Err(e),
|
||||
@ -552,7 +552,7 @@ pub async fn media_current(id: web::Path<i64>) -> Result<impl Responder, Service
|
||||
/// ```
|
||||
#[get("/control/{id}/media/next")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn media_next(id: web::Path<i64>) -> Result<impl Responder, ServiceError> {
|
||||
pub async fn media_next(id: web::Path<i32>) -> Result<impl Responder, ServiceError> {
|
||||
match media_info(*id, "next".into()).await {
|
||||
Ok(res) => Ok(res.text().await.unwrap_or_else(|_| "Success".into())),
|
||||
Err(e) => Err(e),
|
||||
@ -567,7 +567,7 @@ pub async fn media_next(id: web::Path<i64>) -> Result<impl Responder, ServiceErr
|
||||
/// ```
|
||||
#[get("/control/{id}/media/last")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn media_last(id: web::Path<i64>) -> Result<impl Responder, ServiceError> {
|
||||
pub async fn media_last(id: web::Path<i32>) -> Result<impl Responder, ServiceError> {
|
||||
match media_info(*id, "last".into()).await {
|
||||
Ok(res) => Ok(res.text().await.unwrap_or_else(|_| "Success".into())),
|
||||
Err(e) => Err(e),
|
||||
@ -590,7 +590,7 @@ pub async fn media_last(id: web::Path<i64>) -> Result<impl Responder, ServiceErr
|
||||
#[post("/control/{id}/process/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn process_control(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
proc: web::Json<Process>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
control_service(*id, &proc.command).await
|
||||
@ -607,7 +607,7 @@ pub async fn process_control(
|
||||
#[get("/playlist/{id}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn get_playlist(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
obj: web::Query<DateObj>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match read_playlist(*id, obj.date.clone()).await {
|
||||
@ -626,7 +626,7 @@ pub async fn get_playlist(
|
||||
#[post("/playlist/{id}/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn save_playlist(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<JsonPlaylist>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match write_playlist(*id, data.into_inner()).await {
|
||||
@ -646,7 +646,7 @@ pub async fn save_playlist(
|
||||
#[get("/playlist/{id}/generate/{date}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn gen_playlist(
|
||||
params: web::Path<(i64, String)>,
|
||||
params: web::Path<(i32, String)>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match generate_playlist(params.0, params.1.clone()).await {
|
||||
Ok(playlist) => Ok(web::Json(playlist)),
|
||||
@ -663,7 +663,7 @@ pub async fn gen_playlist(
|
||||
#[delete("/playlist/{id}/{date}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn del_playlist(
|
||||
params: web::Path<(i64, String)>,
|
||||
params: web::Path<(i32, String)>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match delete_playlist(params.0, ¶ms.1).await {
|
||||
Ok(_) => Ok(format!("Delete playlist from {} success!", params.1)),
|
||||
@ -682,7 +682,7 @@ pub async fn del_playlist(
|
||||
#[get("/log/{id}")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn get_log(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
log: web::Query<DateObj>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
read_log_file(&id, &log.date).await
|
||||
@ -699,7 +699,7 @@ pub async fn get_log(
|
||||
#[post("/file/{id}/browse/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn file_browser(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<PathObject>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match browser(*id, &data.into_inner()).await {
|
||||
@ -717,7 +717,7 @@ pub async fn file_browser(
|
||||
#[post("/file/{id}/create-folder/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn add_dir(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<PathObject>,
|
||||
) -> Result<HttpResponse, ServiceError> {
|
||||
create_directory(*id, &data.into_inner()).await
|
||||
@ -732,7 +732,7 @@ pub async fn add_dir(
|
||||
#[post("/file/{id}/rename/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn move_rename(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<MoveObject>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match rename_file(*id, &data.into_inner()).await {
|
||||
@ -750,7 +750,7 @@ pub async fn move_rename(
|
||||
#[post("/file/{id}/remove/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
pub async fn remove(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
data: web::Json<PathObject>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
match remove_file_or_folder(*id, &data.into_inner().source).await {
|
||||
@ -768,7 +768,7 @@ pub async fn remove(
|
||||
#[put("/file/{id}/upload/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
async fn save_file(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
payload: Multipart,
|
||||
obj: web::Query<FileObj>,
|
||||
) -> Result<HttpResponse, ServiceError> {
|
||||
@ -787,7 +787,7 @@ async fn save_file(
|
||||
#[put("/file/{id}/import/")]
|
||||
#[has_any_role("Role::Admin", "Role::User", type = "Role")]
|
||||
async fn import_playlist(
|
||||
id: web::Path<i64>,
|
||||
id: web::Path<i32>,
|
||||
payload: Multipart,
|
||||
obj: web::Query<ImportObj>,
|
||||
) -> Result<HttpResponse, ServiceError> {
|
||||
|
@ -143,7 +143,7 @@ pub async fn select_global() -> Result<GlobalSettings, sqlx::Error> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn select_channel(id: &i64) -> Result<Channel, sqlx::Error> {
|
||||
pub async fn select_channel(id: &i32) -> Result<Channel, sqlx::Error> {
|
||||
let conn = connection().await?;
|
||||
let query = "SELECT * FROM channels WHERE id = $1";
|
||||
let mut result: Channel = sqlx::query_as(query).bind(id).fetch_one(&conn).await?;
|
||||
@ -167,7 +167,7 @@ pub async fn select_all_channels() -> Result<Vec<Channel>, sqlx::Error> {
|
||||
Ok(results)
|
||||
}
|
||||
|
||||
pub async fn update_channel(id: i64, channel: Channel) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
pub async fn update_channel(id: i32, channel: Channel) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
let conn = connection().await?;
|
||||
|
||||
let query = "UPDATE channels SET name = $2, preview_url = $3, config_path = $4, extra_extensions = $5 WHERE id = $1";
|
||||
@ -205,7 +205,7 @@ pub async fn insert_channel(channel: Channel) -> Result<Channel, sqlx::Error> {
|
||||
Ok(new_channel)
|
||||
}
|
||||
|
||||
pub async fn delete_channel(id: &i64) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
pub async fn delete_channel(id: &i32) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
let conn = connection().await?;
|
||||
|
||||
let query = "DELETE FROM channels WHERE id = $1";
|
||||
@ -215,7 +215,7 @@ pub async fn delete_channel(id: &i64) -> Result<SqliteQueryResult, sqlx::Error>
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn select_role(id: &i64) -> Result<String, sqlx::Error> {
|
||||
pub async fn select_role(id: &i32) -> Result<String, sqlx::Error> {
|
||||
let conn = connection().await?;
|
||||
let query = "SELECT name FROM roles WHERE id = $1";
|
||||
let result: Role = sqlx::query_as(query).bind(id).fetch_one(&conn).await?;
|
||||
@ -264,7 +264,7 @@ pub async fn insert_user(user: User) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn update_user(id: i64, fields: String) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
pub async fn update_user(id: i32, fields: String) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
let conn = connection().await?;
|
||||
let query = format!("UPDATE user SET {fields} WHERE id = $1");
|
||||
let result: SqliteQueryResult = sqlx::query(&query).bind(id).execute(&conn).await?;
|
||||
@ -273,7 +273,7 @@ pub async fn update_user(id: i64, fields: String) -> Result<SqliteQueryResult, s
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn select_presets(id: i64) -> Result<Vec<TextPreset>, sqlx::Error> {
|
||||
pub async fn select_presets(id: i32) -> Result<Vec<TextPreset>, sqlx::Error> {
|
||||
let conn = connection().await?;
|
||||
let query = "SELECT * FROM presets WHERE channel_id = $1";
|
||||
let result: Vec<TextPreset> = sqlx::query_as(query).bind(id).fetch_all(&conn).await?;
|
||||
@ -282,7 +282,7 @@ pub async fn select_presets(id: i64) -> Result<Vec<TextPreset>, sqlx::Error> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn update_preset(id: &i64, preset: TextPreset) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
pub async fn update_preset(id: &i32, preset: TextPreset) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
let conn = connection().await?;
|
||||
let query =
|
||||
"UPDATE presets SET name = $1, text = $2, x = $3, y = $4, fontsize = $5, line_spacing = $6,
|
||||
@ -332,7 +332,7 @@ pub async fn insert_preset(preset: TextPreset) -> Result<SqliteQueryResult, sqlx
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn delete_preset(id: &i64) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
pub async fn delete_preset(id: &i32) -> Result<SqliteQueryResult, sqlx::Error> {
|
||||
let conn = connection().await?;
|
||||
let query = "DELETE FROM presets WHERE id = $1;";
|
||||
let result: SqliteQueryResult = sqlx::query(query).bind(id).execute(&conn).await?;
|
||||
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
pub struct User {
|
||||
#[sqlx(default)]
|
||||
#[serde(skip_deserializing)]
|
||||
pub id: i64,
|
||||
pub id: i32,
|
||||
#[sqlx(default)]
|
||||
pub mail: Option<String>,
|
||||
pub username: String,
|
||||
@ -16,10 +16,10 @@ pub struct User {
|
||||
pub salt: Option<String>,
|
||||
#[sqlx(default)]
|
||||
#[serde(skip_serializing)]
|
||||
pub role_id: Option<i64>,
|
||||
pub role_id: Option<i32>,
|
||||
#[sqlx(default)]
|
||||
#[serde(skip_serializing)]
|
||||
pub channel_id: Option<i64>,
|
||||
pub channel_id: Option<i32>,
|
||||
#[sqlx(default)]
|
||||
pub token: Option<String>,
|
||||
}
|
||||
@ -30,12 +30,12 @@ fn empty_string() -> String {
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct LoginUser {
|
||||
pub id: i64,
|
||||
pub id: i32,
|
||||
pub username: String,
|
||||
}
|
||||
|
||||
impl LoginUser {
|
||||
pub fn new(id: i64, username: String) -> Self {
|
||||
pub fn new(id: i32, username: String) -> Self {
|
||||
Self { id, username }
|
||||
}
|
||||
}
|
||||
@ -43,8 +43,8 @@ impl LoginUser {
|
||||
pub struct TextPreset {
|
||||
#[sqlx(default)]
|
||||
#[serde(skip_deserializing)]
|
||||
pub id: i64,
|
||||
pub channel_id: i64,
|
||||
pub id: i32,
|
||||
pub channel_id: i32,
|
||||
pub name: String,
|
||||
pub text: String,
|
||||
pub x: String,
|
||||
@ -61,7 +61,7 @@ pub struct TextPreset {
|
||||
#[derive(Debug, Deserialize, Serialize, sqlx::FromRow)]
|
||||
pub struct Channel {
|
||||
#[serde(skip_deserializing)]
|
||||
pub id: i64,
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub preview_url: String,
|
||||
pub config_path: String,
|
||||
|
@ -26,7 +26,7 @@ pub async fn create_channel(target_channel: Channel) -> Result<Channel, ServiceE
|
||||
Ok(new_channel)
|
||||
}
|
||||
|
||||
pub async fn delete_channel(id: i64) -> Result<(), ServiceError> {
|
||||
pub async fn delete_channel(id: i32) -> Result<(), ServiceError> {
|
||||
let channel = handles::select_channel(&id).await?;
|
||||
control_service(channel.id, "stop").await?;
|
||||
control_service(channel.id, "disable").await?;
|
||||
|
@ -13,7 +13,7 @@ use ffplayout_lib::vec_strings;
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
struct RpcObj<T> {
|
||||
jsonrpc: String,
|
||||
id: i64,
|
||||
id: i32,
|
||||
method: String,
|
||||
params: T,
|
||||
}
|
||||
@ -35,7 +35,7 @@ struct MediaParams {
|
||||
}
|
||||
|
||||
impl<T> RpcObj<T> {
|
||||
fn new(id: i64, method: String, params: T) -> Self {
|
||||
fn new(id: i32, method: String, params: T) -> Self {
|
||||
Self {
|
||||
jsonrpc: "2.0".into(),
|
||||
id,
|
||||
@ -56,7 +56,7 @@ struct SystemD {
|
||||
}
|
||||
|
||||
impl SystemD {
|
||||
async fn new(id: i64) -> Result<Self, ServiceError> {
|
||||
async fn new(id: i32) -> Result<Self, ServiceError> {
|
||||
let channel = select_channel(&id).await?;
|
||||
|
||||
Ok(Self {
|
||||
@ -130,7 +130,7 @@ fn create_header(auth: &str) -> HeaderMap {
|
||||
headers
|
||||
}
|
||||
|
||||
async fn post_request<T>(id: i64, obj: RpcObj<T>) -> Result<Response, ServiceError>
|
||||
async fn post_request<T>(id: i32, obj: RpcObj<T>) -> Result<Response, ServiceError>
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
@ -151,7 +151,7 @@ where
|
||||
}
|
||||
|
||||
pub async fn send_message(
|
||||
id: i64,
|
||||
id: i32,
|
||||
message: HashMap<String, String>,
|
||||
) -> Result<Response, ServiceError> {
|
||||
let json_obj = RpcObj::new(
|
||||
@ -166,19 +166,19 @@ pub async fn send_message(
|
||||
post_request(id, json_obj).await
|
||||
}
|
||||
|
||||
pub async fn control_state(id: i64, command: String) -> Result<Response, ServiceError> {
|
||||
pub async fn control_state(id: i32, command: String) -> Result<Response, ServiceError> {
|
||||
let json_obj = RpcObj::new(id, "player".into(), ControlParams { control: command });
|
||||
|
||||
post_request(id, json_obj).await
|
||||
}
|
||||
|
||||
pub async fn media_info(id: i64, command: String) -> Result<Response, ServiceError> {
|
||||
pub async fn media_info(id: i32, command: String) -> Result<Response, ServiceError> {
|
||||
let json_obj = RpcObj::new(id, "player".into(), MediaParams { media: command });
|
||||
|
||||
post_request(id, json_obj).await
|
||||
}
|
||||
|
||||
pub async fn control_service(id: i64, command: &str) -> Result<String, ServiceError> {
|
||||
pub async fn control_service(id: i32, command: &str) -> Result<String, ServiceError> {
|
||||
let system_d = SystemD::new(id).await?;
|
||||
|
||||
match command {
|
||||
|
@ -87,7 +87,7 @@ fn norm_abs_path(root_path: &str, input_path: &str) -> (PathBuf, String, String)
|
||||
/// Take input path and give file and folder list from it back.
|
||||
/// Input should be a relative path segment, but when it is a absolut path, the norm_abs_path function
|
||||
/// will take care, that user can not break out from given storage path in config.
|
||||
pub async fn browser(id: i64, path_obj: &PathObject) -> Result<PathObject, ServiceError> {
|
||||
pub async fn browser(id: i32, path_obj: &PathObject) -> Result<PathObject, ServiceError> {
|
||||
let (config, _) = playout_config(&id).await?;
|
||||
let extensions = config.storage.extensions;
|
||||
let (path, parent, path_component) = norm_abs_path(&config.storage.path, &path_obj.source);
|
||||
@ -143,7 +143,7 @@ pub async fn browser(id: i64, path_obj: &PathObject) -> Result<PathObject, Servi
|
||||
}
|
||||
|
||||
pub async fn create_directory(
|
||||
id: i64,
|
||||
id: i32,
|
||||
path_obj: &PathObject,
|
||||
) -> Result<HttpResponse, ServiceError> {
|
||||
let (config, _) = playout_config(&id).await?;
|
||||
@ -198,7 +198,7 @@ fn rename(source: &PathBuf, target: &PathBuf) -> Result<MoveObject, ServiceError
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn rename_file(id: i64, move_object: &MoveObject) -> Result<MoveObject, ServiceError> {
|
||||
pub async fn rename_file(id: i32, move_object: &MoveObject) -> Result<MoveObject, ServiceError> {
|
||||
let (config, _) = playout_config(&id).await?;
|
||||
let (source_path, _, _) = norm_abs_path(&config.storage.path, &move_object.source);
|
||||
let (mut target_path, _, _) = norm_abs_path(&config.storage.path, &move_object.target);
|
||||
@ -229,7 +229,7 @@ pub async fn rename_file(id: i64, move_object: &MoveObject) -> Result<MoveObject
|
||||
Err(ServiceError::InternalServerError)
|
||||
}
|
||||
|
||||
pub async fn remove_file_or_folder(id: i64, source_path: &str) -> Result<(), ServiceError> {
|
||||
pub async fn remove_file_or_folder(id: i32, source_path: &str) -> Result<(), ServiceError> {
|
||||
let (config, _) = playout_config(&id).await?;
|
||||
let (source, _, _) = norm_abs_path(&config.storage.path, source_path);
|
||||
|
||||
@ -262,7 +262,7 @@ pub async fn remove_file_or_folder(id: i64, source_path: &str) -> Result<(), Ser
|
||||
Err(ServiceError::InternalServerError)
|
||||
}
|
||||
|
||||
async fn valid_path(id: i64, path: &str) -> Result<PathBuf, ServiceError> {
|
||||
async fn valid_path(id: i32, path: &str) -> Result<PathBuf, ServiceError> {
|
||||
let (config, _) = playout_config(&id).await?;
|
||||
let (test_path, _, _) = norm_abs_path(&config.storage.path, path);
|
||||
|
||||
@ -274,7 +274,7 @@ async fn valid_path(id: i64, path: &str) -> Result<PathBuf, ServiceError> {
|
||||
}
|
||||
|
||||
pub async fn upload(
|
||||
id: i64,
|
||||
id: i32,
|
||||
mut payload: Multipart,
|
||||
path: &str,
|
||||
abs_path: bool,
|
||||
|
@ -180,7 +180,7 @@ pub fn read_playout_config(path: &str) -> Result<PlayoutConfig, Box<dyn Error>>
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
pub async fn playout_config(channel_id: &i64) -> Result<(PlayoutConfig, Channel), ServiceError> {
|
||||
pub async fn playout_config(channel_id: &i32) -> Result<(PlayoutConfig, Channel), ServiceError> {
|
||||
if let Ok(channel) = select_channel(channel_id).await {
|
||||
if let Ok(config) = read_playout_config(&channel.config_path.clone()) {
|
||||
return Ok((config, channel));
|
||||
@ -192,7 +192,7 @@ pub async fn playout_config(channel_id: &i64) -> Result<(PlayoutConfig, Channel)
|
||||
))
|
||||
}
|
||||
|
||||
pub async fn read_log_file(channel_id: &i64, date: &str) -> Result<String, ServiceError> {
|
||||
pub async fn read_log_file(channel_id: &i32, date: &str) -> Result<String, ServiceError> {
|
||||
if let Ok(channel) = select_channel(channel_id).await {
|
||||
let mut date_str = "".to_string();
|
||||
|
||||
|
@ -7,7 +7,7 @@ use ffplayout_lib::utils::{
|
||||
generate_playlist as playlist_generator, json_reader, json_writer, JsonPlaylist,
|
||||
};
|
||||
|
||||
pub async fn read_playlist(id: i64, date: String) -> Result<JsonPlaylist, ServiceError> {
|
||||
pub async fn read_playlist(id: i32, date: String) -> Result<JsonPlaylist, ServiceError> {
|
||||
let (config, _) = playout_config(&id).await?;
|
||||
let mut playlist_path = PathBuf::from(&config.playlist.path);
|
||||
let d: Vec<&str> = date.split('-').collect();
|
||||
@ -23,7 +23,7 @@ pub async fn read_playlist(id: i64, date: String) -> Result<JsonPlaylist, Servic
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn write_playlist(id: i64, json_data: JsonPlaylist) -> Result<String, ServiceError> {
|
||||
pub async fn write_playlist(id: i32, json_data: JsonPlaylist) -> Result<String, ServiceError> {
|
||||
let (config, _) = playout_config(&id).await?;
|
||||
let date = json_data.date.clone();
|
||||
let mut playlist_path = PathBuf::from(&config.playlist.path);
|
||||
@ -68,7 +68,7 @@ pub async fn write_playlist(id: i64, json_data: JsonPlaylist) -> Result<String,
|
||||
Err(ServiceError::InternalServerError)
|
||||
}
|
||||
|
||||
pub async fn generate_playlist(id: i64, date: String) -> Result<JsonPlaylist, ServiceError> {
|
||||
pub async fn generate_playlist(id: i32, date: String) -> Result<JsonPlaylist, ServiceError> {
|
||||
let (mut config, channel) = playout_config(&id).await?;
|
||||
config.general.generate = Some(vec![date.clone()]);
|
||||
|
||||
@ -89,7 +89,7 @@ pub async fn generate_playlist(id: i64, date: String) -> Result<JsonPlaylist, Se
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn delete_playlist(id: i64, date: &str) -> Result<(), ServiceError> {
|
||||
pub async fn delete_playlist(id: i32, date: &str) -> Result<(), ServiceError> {
|
||||
let (config, _) = playout_config(&id).await?;
|
||||
let mut playlist_path = PathBuf::from(&config.playlist.path);
|
||||
let d: Vec<&str> = date.split('-').collect();
|
||||
|
@ -301,10 +301,10 @@ pub fn write_status(config: &PlayoutConfig, date: &str, shift: f64) {
|
||||
};
|
||||
}
|
||||
|
||||
// pub fn get_timestamp() -> i64 {
|
||||
// pub fn get_timestamp() -> i32 {
|
||||
// let local: DateTime<Local> = time_now();
|
||||
|
||||
// local.timestamp_millis() as i64
|
||||
// local.timestamp_millis() as i32
|
||||
// }
|
||||
|
||||
/// Get current time in seconds.
|
||||
|
Loading…
Reference in New Issue
Block a user