fix: video embeds
add: listening state api
This commit is contained in:
parent
498884291e
commit
a114d862ae
4 changed files with 39 additions and 11 deletions
|
@ -671,22 +671,22 @@
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
window.localStorage.getItem("atto:connections.last_fm/name") ===
|
|
||||||
playing.name
|
|
||||||
) {
|
|
||||||
// item already pushed to connection, no need right now
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mb_info = await $.pull_track_info(
|
const mb_info = await $.pull_track_info(
|
||||||
playing.artist.name,
|
playing.artist.name,
|
||||||
playing.name,
|
playing.name,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
window.localStorage.getItem("atto:connections.last_fm/name") ===
|
||||||
|
playing.name + mb_info.id
|
||||||
|
) {
|
||||||
|
// item already pushed to connection, no need right now
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
"atto:connections.last_fm/name",
|
"atto:connections.last_fm/name",
|
||||||
playing.name,
|
playing.name + mb_info.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
return await trigger("connections::push_con_state", [
|
return await trigger("connections::push_con_state", [
|
||||||
|
@ -698,7 +698,7 @@
|
||||||
track_img: playing.image[2]["#text"],
|
track_img: playing.image[2]["#text"],
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
id: playing.mbid,
|
id: mb_info.id,
|
||||||
// track
|
// track
|
||||||
track: playing.name,
|
track: playing.name,
|
||||||
artist: playing.artist.name,
|
artist: playing.artist.name,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use axum::{response::IntoResponse, Extension, Json};
|
use axum::{extract::Path, response::IntoResponse, Extension, Json};
|
||||||
use axum_extra::extract::CookieJar;
|
use axum_extra::extract::CookieJar;
|
||||||
use tetratto_core::{
|
use tetratto_core::{
|
||||||
database::connections::last_fm::LastFmConnection,
|
database::connections::last_fm::LastFmConnection,
|
||||||
|
@ -49,6 +49,29 @@ pub async fn create_request(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_request(
|
||||||
|
Extension(data): Extension<State>,
|
||||||
|
Path(username): Path<String>,
|
||||||
|
) -> impl IntoResponse {
|
||||||
|
let data = &(data.read().await).0;
|
||||||
|
|
||||||
|
let profile = match data.get_user_by_username(&username).await {
|
||||||
|
Ok(ua) => ua,
|
||||||
|
Err(e) => return Json(e.into()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let con = match profile.connections.get(&ConnectionService::LastFm) {
|
||||||
|
Some(c) => c,
|
||||||
|
None => return Json(Error::GeneralNotFound("connection".to_string()).into()),
|
||||||
|
};
|
||||||
|
|
||||||
|
Json(ApiReturn {
|
||||||
|
ok: true,
|
||||||
|
message: "Connection exists".to_string(),
|
||||||
|
payload: Some(con.1.clone()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn proxy_request(
|
pub async fn proxy_request(
|
||||||
jar: CookieJar,
|
jar: CookieJar,
|
||||||
Extension(data): Extension<State>,
|
Extension(data): Extension<State>,
|
||||||
|
|
|
@ -258,6 +258,10 @@ pub fn routes() -> Router {
|
||||||
"/auth/user/connections/last_fm",
|
"/auth/user/connections/last_fm",
|
||||||
post(auth::connections::last_fm::create_request),
|
post(auth::connections::last_fm::create_request),
|
||||||
)
|
)
|
||||||
|
.route(
|
||||||
|
"/auth/user/connections/last_fm/data/{username}",
|
||||||
|
get(auth::connections::last_fm::get_request),
|
||||||
|
)
|
||||||
.route(
|
.route(
|
||||||
"/auth/user/connections/last_fm/api_proxy",
|
"/auth/user/connections/last_fm/api_proxy",
|
||||||
post(auth::connections::last_fm::proxy_request),
|
post(auth::connections::last_fm::proxy_request),
|
||||||
|
|
|
@ -26,6 +26,7 @@ pub fn render_markdown(input: &str) -> String {
|
||||||
allowed_attributes.insert("lang");
|
allowed_attributes.insert("lang");
|
||||||
allowed_attributes.insert("title");
|
allowed_attributes.insert("title");
|
||||||
allowed_attributes.insert("align");
|
allowed_attributes.insert("align");
|
||||||
|
allowed_attributes.insert("src");
|
||||||
|
|
||||||
allowed_attributes.insert("data-color");
|
allowed_attributes.insert("data-color");
|
||||||
allowed_attributes.insert("data-font-family");
|
allowed_attributes.insert("data-font-family");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue