Basic Web Push support.

This commit is contained in:
Paul
2021-02-18 16:21:34 +00:00
parent a2f14d2d37
commit 52e070c21c
15 changed files with 277 additions and 52 deletions

View File

@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Options {
ids: Vec<String>
ids: Vec<String>,
}
#[post("/<target>/messages/stale", data = "<data>")]
@@ -35,7 +35,7 @@ pub async fn req(user: User, target: Ref, data: Json<Options>) -> Result<JsonVal
},
"channel": target.id()
},
None
None,
)
.await
.map_err(|_| Error::DatabaseError {
@@ -47,12 +47,11 @@ pub async fn req(user: User, target: Ref, data: Json<Options>) -> Result<JsonVal
let mut found_ids = vec![];
while let Some(result) = cursor.next().await {
if let Ok(doc) = result {
let msg = from_document::<Message>(doc)
.map_err(|_| Error::DatabaseError {
operation: "from_document",
with: "message",
})?;
let msg = from_document::<Message>(doc).map_err(|_| Error::DatabaseError {
operation: "from_document",
with: "message",
})?;
found_ids.push(msg.id.clone());
if msg.edited.is_some() {
updated.push(msg);