From 1b196a2703f3eeab1301d591c9a041330fff72e4 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Wed, 3 Apr 2024 21:07:06 -0700 Subject: [PATCH] server: add ability to add/remove labels --- server/src/graphql.rs | 23 ++++++++++++++++++++++- server/src/lib.rs | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/server/src/graphql.rs b/server/src/graphql.rs index e3d855c..2c3e945 100644 --- a/server/src/graphql.rs +++ b/server/src/graphql.rs @@ -3,7 +3,6 @@ use std::{ collections::HashMap, fs::File, hash::{DefaultHasher, Hash, Hasher}, - str::FromStr, }; use async_graphql::{ @@ -427,6 +426,28 @@ impl Mutation { } Ok(true) } + async fn tag_add<'ctx>( + &self, + ctx: &Context<'ctx>, + query: String, + tag: String, + ) -> Result { + let nm = ctx.data_unchecked::(); + info!("tag_add({tag}, {query})"); + nm.tag_add(&tag, &query)?; + Ok(true) + } + async fn tag_remove<'ctx>( + &self, + ctx: &Context<'ctx>, + query: String, + tag: String, + ) -> Result { + let nm = ctx.data_unchecked::(); + info!("tag_remove({tag}, {query})"); + nm.tag_remove(&tag, &query)?; + Ok(true) + } } pub type GraphqlSchema = Schema; diff --git a/server/src/lib.rs b/server/src/lib.rs index 91d2259..2b9af68 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -83,6 +83,8 @@ pub fn sanitize_html(html: &str) -> Result { } }; // Default's don't allow style, but we want to preserve that. + // TODO: remove 'class' if rendering mails moves to a two phase process where abstract message + // types are collected, santized, and then grouped together as one big HTML doc let attributes = hashset![ "align", "bgcolor", "class", "color", "height", "lang", "title", "width", "style", ];