feat(users): implement fetch self / user, open dm

This commit is contained in:
Paul Makles
2022-01-31 22:30:02 +00:00
parent c1cd4bfa66
commit 1d5800a3b8
8 changed files with 55 additions and 40 deletions

View File

@@ -5,7 +5,7 @@ use std::path::Path;
pub struct CachedFile(NamedFile);
pub static CACHE_CONTROL: &'static str = "public, max-age=31536000, immutable";
pub static CACHE_CONTROL: &str = "public, max-age=31536000, immutable";
impl<'r> Responder<'r, 'static> for CachedFile {
fn respond_to(self, req: &'r Request<'_>) -> response::Result<'static> {
@@ -19,22 +19,22 @@ impl<'r> Responder<'r, 'static> for CachedFile {
pub async fn req(target: String) -> Option<CachedFile> {
match target.chars().nth(25).unwrap() {
'0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' => {
NamedFile::open(Path::new("assets/user_red.png")).await.ok().map(|n| CachedFile(n))
NamedFile::open(Path::new("assets/user_red.png")).await.ok().map(CachedFile)
}
'8' | '9' | 'A' | 'C' | 'B' | 'D' | 'E' | 'F' => {
NamedFile::open(Path::new("assets/user_green.png"))
.await
.ok().map(|n| CachedFile(n))
.ok().map(CachedFile)
}
'G' | 'H' | 'J' | 'K' | 'M' | 'N' | 'P' | 'Q' => {
NamedFile::open(Path::new("assets/user_blue.png"))
.await
.ok().map(|n| CachedFile(n))
.ok().map(CachedFile)
}
'R' | 'S' | 'T' | 'V' | 'W' | 'X' | 'Y' | 'Z' => {
NamedFile::open(Path::new("assets/user_yellow.png"))
.await
.ok().map(|n| CachedFile(n))
.ok().map(CachedFile)
}
_ => unreachable!(),
}