forked from jmug/stoatchat
feat(servers): implement create, delete, edit, fetch
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use revolt_quark::{Result, models::{UserSettings, User}, Db};
|
||||
use revolt_quark::{
|
||||
models::{User, UserSettings},
|
||||
Db, Result,
|
||||
};
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use rocket::serde::json::Json;
|
||||
@@ -11,5 +14,7 @@ pub struct Options {
|
||||
|
||||
#[post("/settings/fetch", data = "<options>")]
|
||||
pub async fn req(db: &Db, user: User, options: Json<Options>) -> Result<Json<UserSettings>> {
|
||||
db.fetch_user_settings(&user.id, &options.into_inner().keys).await.map(Json)
|
||||
db.fetch_user_settings(&user.id, &options.into_inner().keys)
|
||||
.await
|
||||
.map(Json)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use revolt_quark::{Result, models::{ChannelUnread, User}, Db};
|
||||
use revolt_quark::{
|
||||
models::{ChannelUnread, User},
|
||||
Db, Result,
|
||||
};
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use rocket::serde::json::Json;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_quark::models::User;
|
||||
use revolt_quark::{EmptyResponse, Result, Db};
|
||||
use revolt_quark::{Db, EmptyResponse, Result};
|
||||
|
||||
use chrono::prelude::*;
|
||||
use rocket::serde::json::Json;
|
||||
@@ -29,11 +29,10 @@ pub async fn req(db: &Db, user: User, data: Json<Data>, options: Options) -> Res
|
||||
|
||||
let mut settings = HashMap::new();
|
||||
for (key, data) in data {
|
||||
settings.insert(key, (
|
||||
timestamp,
|
||||
data
|
||||
));
|
||||
settings.insert(key, (timestamp, data));
|
||||
}
|
||||
|
||||
db.set_user_settings(&user.id, &settings).await.map(|_| EmptyResponse)
|
||||
db.set_user_settings(&user.id, &settings)
|
||||
.await
|
||||
.map(|_| EmptyResponse)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user