extra_extensions as vec

This commit is contained in:
jb-alvarado 2022-12-21 14:11:27 +01:00
parent 5e6f2ee4a1
commit c4f803da11
4 changed files with 25 additions and 7 deletions

2
Cargo.lock generated
View File

@ -982,7 +982,7 @@ dependencies = [
[[package]]
name = "ffplayout-api"
version = "0.8.3"
version = "0.9.0"
dependencies = [
"actix-files",
"actix-multipart",

View File

@ -4,7 +4,7 @@ description = "Rest API for ffplayout"
license = "GPL-3.0"
authors = ["Jonathan Baecker jonbae77@gmail.com"]
readme = "README.md"
version = "0.8.3"
version = "0.9.0"
edition = "2021"
[dependencies]

View File

@ -168,7 +168,7 @@ pub async fn update_channel(
.bind(channel.name)
.bind(channel.preview_url)
.bind(channel.config_path)
.bind(channel.extra_extensions)
.bind(channel.extra_extensions.join(","))
.execute(conn)
.await
}
@ -179,7 +179,7 @@ pub async fn insert_channel(conn: &Pool<Sqlite>, channel: Channel) -> Result<Cha
.bind(channel.name)
.bind(channel.preview_url)
.bind(channel.config_path)
.bind(channel.extra_extensions)
.bind(channel.extra_extensions.join(","))
.bind(channel.service)
.execute(conn)
.await?;

View File

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use sqlx::{sqlite::SqliteRow, FromRow, Row};
#[derive(Debug, Deserialize, Serialize, sqlx::FromRow)]
pub struct User {
@ -58,17 +59,34 @@ pub struct TextPreset {
pub alpha: String,
}
#[derive(Debug, Deserialize, Serialize, sqlx::FromRow)]
#[derive(Debug, Deserialize, Serialize, sqlx::Type)]
pub struct Channel {
#[serde(skip_deserializing)]
pub id: i32,
pub name: String,
pub preview_url: String,
pub config_path: String,
pub extra_extensions: String,
pub extra_extensions: Vec<String>,
pub service: String,
#[sqlx(default)]
#[serde(default)]
pub utc_offset: i32,
}
impl FromRow<'_, SqliteRow> for Channel {
fn from_row(row: &SqliteRow) -> sqlx::Result<Self> {
Ok(Self {
id: row.get("id"),
name: row.get("name"),
preview_url: row.get("preview_url"),
config_path: row.get("config_path"),
extra_extensions: row
.get::<String, &str>("extra_extensions")
.split(',')
.map(|s| s.to_string())
.collect(),
service: row.get("service"),
utc_offset: 0,
})
}
}