Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Create series" API and route #1325

Draft
wants to merge 24 commits into
base: next
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
05ef60c
Generalize event table backend logic
owi92 Dec 17, 2024
c1f96b2
Generalize frontend event table
owi92 Jan 7, 2025
8b93e1f
Add `my-series` route
owi92 Jan 9, 2025
5b9e322
Rework sorting code to allow custom columns
owi92 Jan 10, 2025
d90d7ed
Drastically rework asset table frontend
owi92 Jan 12, 2025
ad9d1a2
Add event count to `My series` table
owi92 Jan 13, 2025
0cb6e8f
Alternative approach to event count acquisition
owi92 Jan 13, 2025
c0c95da
Revise asset type generation, again
owi92 Jan 18, 2025
2a0d04d
Add `updated` column to series and event tables
owi92 Jan 27, 2025
14da37c
Adjust query and `LoadableAsset` to include deleted events
owi92 Feb 5, 2025
650e78a
Rename `Asset` to `Item`
owi92 Feb 9, 2025
507dbc9
Slim down Item type, simplify some code
owi92 Feb 9, 2025
da2bcb6
Add `Shared` folder, move table code
owi92 Jan 15, 2025
2be0bd2
Refactor `manage` code and add series details page
owi92 Jan 15, 2025
ac94d8b
Add series ACL page
owi92 Jan 21, 2025
7246cae
Add API for changing video/series metadata
owi92 Feb 3, 2025
e67fde4
Add mutation and UI for series metadata update
owi92 Feb 3, 2025
7d15ef6
Add migration, API and mutation for series deletion
owi92 Feb 6, 2025
df882ee
Add series deletion related UI features in frontend
owi92 Feb 6, 2025
4a272a5
Add host realms section to series details
owi92 Feb 11, 2025
83dc2e5
Disable ACL editing when series is unsynced
owi92 Feb 11, 2025
b6575a9
Add API to create series in Tobira
owi92 Jan 28, 2025
0ad00d4
Add "Create series" route
owi92 Jan 28, 2025
bc2f541
Change ordering of manage nav items
owi92 Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions backend/src/api/common.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
use bincode::Options;
use juniper::{GraphQLScalar, InputValue, ScalarValue};
use serde::{Deserialize, Serialize};

use crate::{
api::{
Id,
Context,
err::{self, ApiResult},
model::{
event::AuthorizedEvent,
series::Series,
@@ -15,7 +10,6 @@ use crate::{
search::{SearchEvent, SearchRealm, SearchSeries},
},
},
prelude::*,
search::Playlist as SearchPlaylist,
};

@@ -46,56 +40,3 @@ pub(crate) trait Node {
pub(crate) struct NotAllowed;

super::util::impl_object_with_dummy_field!(NotAllowed);


/// Opaque cursor for pagination. Serializes as string.
///
/// Ideally, this would be generic over something `Serialize + Deserialize`.
/// However, junipers `graphql_scalar` macro doesn't work with generics
/// (sigh). So it's easier to just eagerly create the base64 string in `new`
/// and `deserialize`.
///
/// The actual cursor is a base64 encoded string. The encoded bytes are the
/// serialization format from `bincode`, a compact binary serializer. Of course
/// we could also have serialized it as JSON and base64 encoded it then, but
/// that would be a waste of network bandwidth.
#[derive(Debug, Clone, GraphQLScalar)]
#[graphql(
description = "An opaque cursor used for pagination",
parse_token(String),
)]
pub(crate) struct Cursor(String);

impl Cursor {
pub(crate) fn new(data: impl Serialize) -> Self {
let mut b64writer = base64::write::EncoderStringWriter::new(
&base64::engine::general_purpose::URL_SAFE_NO_PAD,
);
bincode::DefaultOptions::new().serialize_into(&mut b64writer, &data)
.unwrap_or_else(|e| unreachable!("bincode serialize failed without size limit: {}", e));
Self(b64writer.into_inner())
}

pub(crate) fn deserialize<T>(&self) -> ApiResult<T>
where
for<'de> T: Deserialize<'de>,
{
let mut bytes = self.0.as_bytes();
let b64reader = base64::read::DecoderReader::new(
&mut bytes,
&base64::engine::general_purpose::URL_SAFE_NO_PAD,
);
bincode::DefaultOptions::new()
.deserialize_from(b64reader)
.map_err(|e| err::invalid_input!("given cursor is invalid: {}", e))
}

fn to_output<S: ScalarValue>(&self) -> juniper::Value<S> {
juniper::Value::scalar(self.0.clone())
}

fn from_input<S: ScalarValue>(input: &InputValue<S>) -> Result<Self, String> {
let s = input.as_string_value().ok_or("expected string")?;
Ok(Self(s.into()))
}
}
2 changes: 1 addition & 1 deletion backend/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ mod subscription;
pub(crate) use self::{
id::Id,
context::Context,
common::{Cursor, Node, NodeValue},
common::{Node, NodeValue},
};


Loading