From 5ba8b8d6ae20719732c84496c896bcdfbfd9ebfe Mon Sep 17 00:00:00 2001 From: silverpill Date: Thu, 23 Mar 2023 18:35:05 +0000 Subject: [PATCH] Move microsyntax parsers to mastodon_api::statuses::microsyntax module --- src/mastodon_api/statuses/helpers.rs | 10 ++++++---- .../statuses/microsyntax}/emojis.rs | 0 .../statuses/microsyntax}/hashtags.rs | 0 .../statuses/microsyntax}/links.rs | 2 +- .../statuses/microsyntax}/mentions.rs | 0 src/mastodon_api/statuses/microsyntax/mod.rs | 4 ++++ src/mastodon_api/statuses/mod.rs | 1 + src/models/posts/mod.rs | 4 ---- 8 files changed, 12 insertions(+), 9 deletions(-) rename src/{models/posts => mastodon_api/statuses/microsyntax}/emojis.rs (100%) rename src/{models/posts => mastodon_api/statuses/microsyntax}/hashtags.rs (100%) rename src/{models/posts => mastodon_api/statuses/microsyntax}/links.rs (98%) rename src/{models/posts => mastodon_api/statuses/microsyntax}/mentions.rs (100%) create mode 100644 src/mastodon_api/statuses/microsyntax/mod.rs diff --git a/src/mastodon_api/statuses/helpers.rs b/src/mastodon_api/statuses/helpers.rs index 53f058d..2089c87 100644 --- a/src/mastodon_api/statuses/helpers.rs +++ b/src/mastodon_api/statuses/helpers.rs @@ -6,15 +6,17 @@ use crate::database::{DatabaseClient, DatabaseError}; use crate::models::{ emojis::types::DbEmoji, posts::{ - emojis::find_emojis, - hashtags::{find_hashtags, replace_hashtags}, helpers::{add_related_posts, add_user_actions}, - links::{replace_object_links, find_linked_posts}, - mentions::{find_mentioned_profiles, replace_mentions}, types::Post, }, users::types::User, }; +use super::microsyntax::{ + emojis::find_emojis, + hashtags::{find_hashtags, replace_hashtags}, + links::{replace_object_links, find_linked_posts}, + mentions::{find_mentioned_profiles, replace_mentions}, +}; use super::types::Status; pub struct PostContent { diff --git a/src/models/posts/emojis.rs b/src/mastodon_api/statuses/microsyntax/emojis.rs similarity index 100% rename from src/models/posts/emojis.rs rename to src/mastodon_api/statuses/microsyntax/emojis.rs diff --git a/src/models/posts/hashtags.rs b/src/mastodon_api/statuses/microsyntax/hashtags.rs similarity index 100% rename from src/models/posts/hashtags.rs rename to src/mastodon_api/statuses/microsyntax/hashtags.rs diff --git a/src/models/posts/links.rs b/src/mastodon_api/statuses/microsyntax/links.rs similarity index 98% rename from src/models/posts/links.rs rename to src/mastodon_api/statuses/microsyntax/links.rs index 3e3ca19..704cc25 100644 --- a/src/models/posts/links.rs +++ b/src/mastodon_api/statuses/microsyntax/links.rs @@ -4,7 +4,7 @@ use regex::{Captures, Match, Regex}; use crate::activitypub::fetcher::helpers::get_post_by_object_id; use crate::database::{DatabaseClient, DatabaseError}; -use super::types::{Post, Visibility}; +use crate::models::posts::types::{Post, Visibility}; // MediaWiki-like syntax: [[url|text]] const OBJECT_LINK_SEARCH_RE: &str = r"(?m)\[\[(?P[^\s\|]+)(\|(?P.+?))?\]\]"; diff --git a/src/models/posts/mentions.rs b/src/mastodon_api/statuses/microsyntax/mentions.rs similarity index 100% rename from src/models/posts/mentions.rs rename to src/mastodon_api/statuses/microsyntax/mentions.rs diff --git a/src/mastodon_api/statuses/microsyntax/mod.rs b/src/mastodon_api/statuses/microsyntax/mod.rs new file mode 100644 index 0000000..4b7f955 --- /dev/null +++ b/src/mastodon_api/statuses/microsyntax/mod.rs @@ -0,0 +1,4 @@ +pub mod emojis; +pub mod hashtags; +pub mod links; +pub mod mentions; diff --git a/src/mastodon_api/statuses/mod.rs b/src/mastodon_api/statuses/mod.rs index e681737..61325ee 100644 --- a/src/mastodon_api/statuses/mod.rs +++ b/src/mastodon_api/statuses/mod.rs @@ -1,3 +1,4 @@ pub mod helpers; +mod microsyntax; pub mod types; pub mod views; diff --git a/src/models/posts/mod.rs b/src/models/posts/mod.rs index 143bcec..391d9b9 100644 --- a/src/models/posts/mod.rs +++ b/src/models/posts/mod.rs @@ -1,7 +1,3 @@ -pub mod emojis; -pub mod hashtags; pub mod helpers; -pub mod links; -pub mod mentions; pub mod queries; pub mod types;