feat(bots): implement bot routes

This commit is contained in:
Paul Makles
2022-02-10 15:54:41 +00:00
parent d4aff072a8
commit a8d5fcec9e
12 changed files with 206 additions and 58 deletions

View File

@@ -1,14 +1,18 @@
use revolt_quark::{EmptyResponse, Error, Result, Ref, models::User, Db, perms};
use revolt_quark::{models::User, perms, Db, EmptyResponse, Error, Ref, Result};
#[put("/<target>/ack/<message>")]
pub async fn req(
db: &Db,
user: User, target: Ref, message: Ref
) -> Result<EmptyResponse> {
pub async fn req(db: &Db, user: User, target: Ref, message: Ref) -> Result<EmptyResponse> {
let channel = target.as_channel(db).await?;
if !perms(&user).channel(&channel).calc_channel(db).await.get_view() {
return Err(Error::NotFound)
if !perms(&user)
.channel(&channel)
.calc_channel(db)
.await
.get_view()
{
return Err(Error::NotFound);
}
db.acknowledge_message(channel.id(), &user.id, &message.id).await.map(|_| EmptyResponse)
db.acknowledge_message(channel.id(), &user.id, &message.id)
.await
.map(|_| EmptyResponse)
}

View File

@@ -10,5 +10,5 @@ struct CreateUserResponse {
#[post("/<_target>/join_call")]
pub async fn req(_user: User, _target: Ref) -> Result<Value> {
todo!()
unimplemented!()
}