blob: 53a3cace2e0c70a506e482a27fb2c51004afe47a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
use crate::database;
use crate::errors::Error;
use crate::spotify;
use rocket::response::Redirect;
#[get("/callback/<name>/<url>")]
pub fn get_tracks(name: String, url: String) -> Result<(), Error> {
let (spotify_uid, spotify_client) = spotify::auth_user(name.as_ref(), url)?;
let uid = database::insert_user(spotify_uid.as_ref())?;
spotify::load_profile(uid, spotify_uid.as_ref(), spotify_client)
}
#[get("/token/<name>")]
pub fn token(name: String) -> Result<Redirect, Error> {
Ok(Redirect::to(spotify::token(name)?))
}
#[get("/match/<name1>/<name2>")]
pub fn match_users(name1: String, name2: String) -> Result<String, Error> {
database::match_users(name1, name2)
}
#[get("/user")]
pub fn get_users() -> Result<String, Error> {
database::get_users()
}
|