Add some new entities & update some existing ones
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// Represents a weekly bucket of instance activity.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub struct Activity {
|
||||||
|
/// Midnight at the first day of the week.
|
||||||
|
pub week: String,
|
||||||
|
/// Statuses created since the week began.
|
||||||
|
pub statuses: String,
|
||||||
|
/// User logins since the week began.
|
||||||
|
pub logins: String,
|
||||||
|
/// User registrations since the week began.
|
||||||
|
pub registrations: String,
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// Custom emoji fields for AnnouncementReaction
|
||||||
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub struct AnnouncementReactionCustomEmoji {
|
||||||
|
/// A link to the custom emoji.
|
||||||
|
pub url: String,
|
||||||
|
/// A link to a non-animated version of the custom emoji.
|
||||||
|
pub static_url: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Represents an emoji reaction to an Announcement.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub struct AnnouncementReaction {
|
||||||
|
/// The emoji used for the reaction. Either a unicode emoji, or a custom emoji's shortcode.
|
||||||
|
pub name: String,
|
||||||
|
/// The total number of users who have added this reaction.
|
||||||
|
pub count: u64,
|
||||||
|
/// Whether the authorized user has added this reaction to the announcement.
|
||||||
|
pub me: bool,
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub emoji: Option<AnnouncementReactionCustomEmoji>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Represents an announcement set by an administrator.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub struct Announcement {
|
||||||
|
/// The announcement id.
|
||||||
|
id: String,
|
||||||
|
/// The content of the announcement.
|
||||||
|
text: String,
|
||||||
|
/// Whether the announcement is currently active.
|
||||||
|
published: bool,
|
||||||
|
/// Whether the announcement has a start/end time.
|
||||||
|
all_day: bool,
|
||||||
|
/// When the announcement was created.
|
||||||
|
created_at: String, // Datetime
|
||||||
|
/// When the announcement was last updated.
|
||||||
|
updated_at: String, // Datetime
|
||||||
|
/// Whether the announcement has been read by the user.
|
||||||
|
read: bool,
|
||||||
|
/// Emoji reactions attached to the announcement.
|
||||||
|
reactions: Vec<AnnouncementReaction>,
|
||||||
|
/// When the future announcement was scheduled.
|
||||||
|
scheduled_at: Option<String>, // Datetime
|
||||||
|
/// When the future announcement will start.
|
||||||
|
starts_at: Option<String>, // Datetime
|
||||||
|
/// When the future announcement will end.
|
||||||
|
ends_at: Option<String>, // Datetime
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ use serde::Deserialize;
|
|||||||
|
|
||||||
/// Data structures for ser/de of account-related resources
|
/// Data structures for ser/de of account-related resources
|
||||||
pub mod account;
|
pub mod account;
|
||||||
|
/// Data structures for ser/de of activity-related resources
|
||||||
|
pub mod activity;
|
||||||
/// Data structures for ser/de of attachment-related resources
|
/// Data structures for ser/de of attachment-related resources
|
||||||
pub mod attachment;
|
pub mod attachment;
|
||||||
/// Data structures for ser/de of card-related resources
|
/// Data structures for ser/de of card-related resources
|
||||||
@@ -21,6 +23,8 @@ pub mod list;
|
|||||||
pub mod mention;
|
pub mod mention;
|
||||||
/// Data structures for ser/de of notification-related resources
|
/// Data structures for ser/de of notification-related resources
|
||||||
pub mod notification;
|
pub mod notification;
|
||||||
|
/// Data structures for ser/de of poll resources
|
||||||
|
pub mod poll;
|
||||||
/// Data structures for ser/de of push-subscription-related resources
|
/// Data structures for ser/de of push-subscription-related resources
|
||||||
pub mod push;
|
pub mod push;
|
||||||
/// Data structures for ser/de of relationship-related resources
|
/// Data structures for ser/de of relationship-related resources
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
use crate::entities::status::Emoji;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// Represents a poll attached to a status.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub struct Poll {
|
||||||
|
/// The ID of the poll in the database.
|
||||||
|
pub id: String,
|
||||||
|
/// When the poll ends.
|
||||||
|
pub expires_at: String, // Datetime??
|
||||||
|
/// Is the poll currently expired?
|
||||||
|
pub expired: bool,
|
||||||
|
/// Does the poll allow multiple-choice answers?
|
||||||
|
pub multiple: bool,
|
||||||
|
/// How many votes have been received.
|
||||||
|
pub votes_count: u64,
|
||||||
|
/// How many unique accounts have voted on a multiple-choice poll.
|
||||||
|
pub voters_count: Option<u64>,
|
||||||
|
/// When called with a user token, has the authorized user voted?
|
||||||
|
pub voted: Option<bool>,
|
||||||
|
/// When called with a user token, which options has the authorized user
|
||||||
|
/// chosen? Contains an array of index values for options
|
||||||
|
pub own_votes: Option<Vec<u64>>,
|
||||||
|
/// Possible answers for the poll.
|
||||||
|
pub options: Vec<PollOption>,
|
||||||
|
/// Custom emoji to be used for rendering poll options.
|
||||||
|
pub emojis: Vec<Emoji>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Possible answers for the poll.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub struct PollOption {
|
||||||
|
/// The text value of the poll option.
|
||||||
|
pub title: String,
|
||||||
|
/// The number of received votes for this option.
|
||||||
|
pub votes_count: Option<u64>,
|
||||||
|
}
|
||||||
+64
-37
@@ -1,9 +1,15 @@
|
|||||||
//! Module containing all info relating to a status.
|
//! Module containing all info relating to a status.
|
||||||
|
|
||||||
use super::prelude::*;
|
use super::prelude::*;
|
||||||
use crate::{entities::card::Card, status_builder::Visibility};
|
use crate::{
|
||||||
|
entities::{
|
||||||
|
card::Card,
|
||||||
|
poll::Poll,
|
||||||
|
},
|
||||||
|
status_builder::Visibility
|
||||||
|
};
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A status from the instance.
|
/// A status from the instance.
|
||||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||||
@@ -12,10 +18,38 @@ pub struct Status {
|
|||||||
pub id: String,
|
pub id: String,
|
||||||
/// A Fediverse-unique resource ID.
|
/// A Fediverse-unique resource ID.
|
||||||
pub uri: String,
|
pub uri: String,
|
||||||
/// URL to the status page (can be remote)
|
/// The time the status was created.
|
||||||
pub url: Option<String>,
|
pub created_at: DateTime<Utc>,
|
||||||
/// The Account which posted the status.
|
/// The Account which posted the status.
|
||||||
pub account: Account,
|
pub account: Account,
|
||||||
|
/// Body of the status; this will contain HTML
|
||||||
|
/// (remote HTML already sanitized)
|
||||||
|
pub content: String,
|
||||||
|
/// The visibilty of the status.
|
||||||
|
pub visibility: Visibility,
|
||||||
|
/// Whether media attachments should be hidden by default.
|
||||||
|
pub sensitive: bool,
|
||||||
|
/// If not empty, warning text that should be displayed before the actual
|
||||||
|
/// content.
|
||||||
|
pub spoiler_text: String,
|
||||||
|
/// An array of attachments.
|
||||||
|
pub media_attachments: Vec<Attachment>,
|
||||||
|
/// Name of application used to post status.
|
||||||
|
pub application: Option<Application>,
|
||||||
|
/// An array of mentions.
|
||||||
|
pub mentions: Vec<Mention>,
|
||||||
|
/// An array of tags.
|
||||||
|
pub tags: Vec<Tag>,
|
||||||
|
/// An array of Emoji
|
||||||
|
pub emojis: Vec<Emoji>,
|
||||||
|
/// The number of reblogs for the status.
|
||||||
|
pub reblogs_count: u64,
|
||||||
|
/// The number of favourites for the status.
|
||||||
|
pub favourites_count: u64,
|
||||||
|
/// The numbef or replies to this status.
|
||||||
|
pub replies_count: Option<u64>,
|
||||||
|
/// URL to the status page (can be remote)
|
||||||
|
pub url: Option<String>,
|
||||||
/// The ID of the status this status is replying to, if the status is
|
/// The ID of the status this status is replying to, if the status is
|
||||||
/// a reply.
|
/// a reply.
|
||||||
pub in_reply_to_id: Option<String>,
|
pub in_reply_to_id: Option<String>,
|
||||||
@@ -24,42 +58,22 @@ pub struct Status {
|
|||||||
pub in_reply_to_account_id: Option<String>,
|
pub in_reply_to_account_id: Option<String>,
|
||||||
/// If this status is a reblogged Status of another User.
|
/// If this status is a reblogged Status of another User.
|
||||||
pub reblog: Option<Box<Status>>,
|
pub reblog: Option<Box<Status>>,
|
||||||
/// Body of the status; this will contain HTML
|
/// The poll attached to the status.
|
||||||
/// (remote HTML already sanitized)
|
pub poll: Option<Poll>,
|
||||||
pub content: String,
|
|
||||||
/// The time the status was created.
|
|
||||||
pub created_at: DateTime<Utc>,
|
|
||||||
/// An array of Emoji
|
|
||||||
pub emojis: Vec<Emoji>,
|
|
||||||
/// The numbef or replies to this status.
|
|
||||||
pub replies_count: Option<u64>,
|
|
||||||
/// The number of reblogs for the status.
|
|
||||||
pub reblogs_count: u64,
|
|
||||||
/// The number of favourites for the status.
|
|
||||||
pub favourites_count: u64,
|
|
||||||
/// Whether the application client has reblogged the status.
|
|
||||||
pub reblogged: Option<bool>,
|
|
||||||
/// Whether the application client has favourited the status.
|
|
||||||
pub favourited: Option<bool>,
|
|
||||||
/// Whether media attachments should be hidden by default.
|
|
||||||
pub sensitive: bool,
|
|
||||||
/// If not empty, warning text that should be displayed before the actual
|
|
||||||
/// content.
|
|
||||||
pub spoiler_text: String,
|
|
||||||
/// The visibilty of the status.
|
|
||||||
pub visibility: Visibility,
|
|
||||||
/// An array of attachments.
|
|
||||||
pub media_attachments: Vec<Attachment>,
|
|
||||||
/// An array of mentions.
|
|
||||||
pub mentions: Vec<Mention>,
|
|
||||||
/// An array of tags.
|
|
||||||
pub tags: Vec<Tag>,
|
|
||||||
/// The associated card
|
/// The associated card
|
||||||
pub card: Option<Card>,
|
pub card: Option<Card>,
|
||||||
/// Name of application used to post status.
|
|
||||||
pub application: Option<Application>,
|
|
||||||
/// The detected language for the status, if detected.
|
/// The detected language for the status, if detected.
|
||||||
pub language: Option<String>,
|
pub language: Option<String>,
|
||||||
|
/// Plain-text source of a status. Returned instead of content when status is deleted, so the user may redraft from the source text without the client having to reverse-engineer the original text from the HTML content.
|
||||||
|
pub text: Option<String>,
|
||||||
|
/// Whether the application client has favourited the status.
|
||||||
|
pub favourited: Option<bool>,
|
||||||
|
/// Whether the application client has reblogged the status.
|
||||||
|
pub reblogged: Option<bool>,
|
||||||
|
/// Have you muted notifications for this status's conversation?
|
||||||
|
pub muted: Option<bool>,
|
||||||
|
/// Have you bookmarked this status?
|
||||||
|
pub bookmarked: Option<bool>,
|
||||||
/// Whether this is the pinned status for the account that posted it.
|
/// Whether this is the pinned status for the account that posted it.
|
||||||
pub pinned: Option<bool>,
|
pub pinned: Option<bool>,
|
||||||
}
|
}
|
||||||
@@ -78,7 +92,7 @@ pub struct Mention {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Struct representing an emoji within text.
|
/// Struct representing an emoji within text.
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||||
pub struct Emoji {
|
pub struct Emoji {
|
||||||
/// The shortcode of the emoji
|
/// The shortcode of the emoji
|
||||||
pub shortcode: String,
|
pub shortcode: String,
|
||||||
@@ -95,6 +109,19 @@ pub struct Tag {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
/// The URL of the hashtag.
|
/// The URL of the hashtag.
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
/// Usage statistics for given days.
|
||||||
|
pub history: Option<Vec<History>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Represents daily usage history of a hashtag.
|
||||||
|
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||||
|
pub struct History {
|
||||||
|
/// UNIX timestamp on midnight of the given day.
|
||||||
|
day: String,
|
||||||
|
/// the counted usage of the tag within that day.
|
||||||
|
uses: String,
|
||||||
|
/// the total of accounts using the tag within that day.
|
||||||
|
accounts: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Application details.
|
/// Application details.
|
||||||
|
|||||||
Reference in New Issue
Block a user