Keyword/filtering API

This adds the 5 methods for the mastodon API that deal with keyword
filtering:

GET /api/v1/filters
POST /api/v1/filters
GET /api/v1/filters/:id
PUT /api/v1/filters/:id
DELETE /api/v1/filters/:id

Closes #71
This commit is contained in:
Paul Woolcock
2018-09-14 05:11:45 -04:00
parent d6a9911a0b
commit 7d164cb8db
6 changed files with 265 additions and 22 deletions
+27
View File
@@ -0,0 +1,27 @@
/// Represents a single Filter
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Filter {
id: String,
phrase: String,
context: Vec<FilterContext>,
expires_at: Option<String>, // TODO: timestamp
irreversible: bool,
whole_word: bool,
}
/// Represents the various types of Filter contexts
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum FilterContext {
/// Represents the "home" context
#[serde(rename = "home")]
Home,
/// Represents the "notifications" context
#[serde(rename = "notifications")]
Notifications,
/// Represents the "public" context
#[serde(rename = "public")]
Public,
/// Represents the "thread" context
#[serde(rename = "thread")]
Thread,
}
+3
View File
@@ -6,6 +6,8 @@ pub mod attachment;
pub mod card;
/// Data structures for ser/de of contetx-related resources
pub mod context;
/// Data structures for ser/de of filter-related resources
pub mod filter;
/// Data structures for ser/de of instance-related resources
pub mod instance;
pub(crate) mod itemsiter;
@@ -39,6 +41,7 @@ pub mod prelude {
attachment::{Attachment, MediaType},
card::Card,
context::Context,
filter::{Filter, FilterContext},
instance::*,
list::List,
mention::Mention,