-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from h3poteto/iss-90
refs #90 Add announcement
- Loading branch information
Showing
22 changed files
with
528 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use super::{status, Emoji}; | ||
use chrono::{DateTime, Utc}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct Announcement { | ||
pub id: String, | ||
pub conent: String, | ||
pub starts_at: Option<DateTime<Utc>>, | ||
pub ends_at: Option<DateTime<Utc>>, | ||
pub published: bool, | ||
pub all_day: bool, | ||
pub published_at: DateTime<Utc>, | ||
pub updated_at: DateTime<Utc>, | ||
pub read: Option<bool>, | ||
pub mentions: Vec<Account>, | ||
pub statuses: Vec<Status>, | ||
pub tags: Vec<status::Tag>, | ||
pub emojis: Vec<Emoji>, | ||
pub reactions: Vec<Reaction>, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct Account { | ||
pub id: String, | ||
pub username: String, | ||
pub url: String, | ||
pub acct: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct Status { | ||
pub id: String, | ||
pub url: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct Reaction { | ||
pub name: String, | ||
pub count: i64, | ||
pub me: Option<bool>, | ||
pub url: Option<String>, | ||
pub static_url: Option<String>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ pub struct Emoji { | |
pub static_url: String, | ||
pub url: String, | ||
pub visible_in_picker: bool, | ||
pub category: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
use super::{status, Emoji}; | ||
use crate::entities as MegalodonEntities; | ||
use chrono::{DateTime, Utc}; | ||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct Announcement { | ||
id: String, | ||
conent: String, | ||
starts_at: Option<DateTime<Utc>>, | ||
ends_at: Option<DateTime<Utc>>, | ||
published: bool, | ||
all_day: bool, | ||
published_at: DateTime<Utc>, | ||
updated_at: DateTime<Utc>, | ||
read: Option<bool>, | ||
mentions: Vec<Account>, | ||
statuses: Vec<Status>, | ||
tags: Vec<status::Tag>, | ||
emojis: Vec<Emoji>, | ||
reactions: Vec<Reaction>, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct Account { | ||
id: String, | ||
username: String, | ||
url: String, | ||
acct: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct Status { | ||
id: String, | ||
url: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct Reaction { | ||
name: String, | ||
count: i64, | ||
me: Option<bool>, | ||
url: Option<String>, | ||
static_url: Option<String>, | ||
} | ||
|
||
impl Into<MegalodonEntities::Announcement> for Announcement { | ||
fn into(self) -> MegalodonEntities::Announcement { | ||
MegalodonEntities::Announcement { | ||
id: self.id, | ||
conent: self.conent, | ||
starts_at: self.starts_at, | ||
ends_at: self.ends_at, | ||
published: self.published, | ||
all_day: self.all_day, | ||
published_at: self.published_at, | ||
updated_at: self.updated_at, | ||
read: self.read, | ||
mentions: self.mentions.into_iter().map(|i| i.into()).collect(), | ||
statuses: self.statuses.into_iter().map(|i| i.into()).collect(), | ||
tags: self.tags.into_iter().map(|i| i.into()).collect(), | ||
emojis: self.emojis.into_iter().map(|i| i.into()).collect(), | ||
reactions: self.reactions.into_iter().map(|i| i.into()).collect(), | ||
} | ||
} | ||
} | ||
|
||
impl Into<MegalodonEntities::announcement::Account> for Account { | ||
fn into(self) -> MegalodonEntities::announcement::Account { | ||
MegalodonEntities::announcement::Account { | ||
id: self.id, | ||
username: self.username, | ||
url: self.url, | ||
acct: self.acct, | ||
} | ||
} | ||
} | ||
|
||
impl Into<MegalodonEntities::announcement::Status> for Status { | ||
fn into(self) -> MegalodonEntities::announcement::Status { | ||
MegalodonEntities::announcement::Status { | ||
id: self.id, | ||
url: self.url, | ||
} | ||
} | ||
} | ||
|
||
impl Into<MegalodonEntities::announcement::Reaction> for Reaction { | ||
fn into(self) -> MegalodonEntities::announcement::Reaction { | ||
MegalodonEntities::announcement::Reaction { | ||
name: self.name, | ||
count: self.count, | ||
me: self.me, | ||
url: self.url, | ||
static_url: self.static_url, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.