Add e621 flags object to SeachResult site_info

This commit is contained in:
Oreo 2024-07-07 00:45:08 -07:00
parent b865efb762
commit 010ff9407b
2 changed files with 17 additions and 1 deletions

View File

@ -91,6 +91,7 @@ pub async fn image_query(
hashes.searched_hash, hashes.searched_hash,
hashes.distance, hashes.distance,
submission.file_sha256 sha256 submission.file_sha256 sha256
null flags
FROM hashes FROM hashes
JOIN submission ON hashes.found_hash = submission.hash_int JOIN submission ON hashes.found_hash = submission.hash_int
JOIN artist ON submission.artist_id = artist.id JOIN artist ON submission.artist_id = artist.id
@ -109,7 +110,8 @@ pub async fn image_query(
to_timestamp(data->>'created_at', 'YYYY-MM-DD"T"HH24:MI:SS"Z"') posted_at, to_timestamp(data->>'created_at', 'YYYY-MM-DD"T"HH24:MI:SS"Z"') posted_at,
hashes.searched_hash, hashes.searched_hash,
hashes.distance, hashes.distance,
e621.sha256 e621.sha256,
e621.data->>'flags' flags
FROM hashes FROM hashes
JOIN e621 ON hashes.found_hash = e621.hash JOIN e621 ON hashes.found_hash = e621.hash
WHERE e621.hash IN (SELECT hashes.found_hash) WHERE e621.hash IN (SELECT hashes.found_hash)
@ -128,6 +130,7 @@ pub async fn image_query(
hashes.searched_hash, hashes.searched_hash,
hashes.distance, hashes.distance,
weasyl.sha256 weasyl.sha256
null flags
FROM hashes FROM hashes
JOIN weasyl ON hashes.found_hash = weasyl.hash JOIN weasyl ON hashes.found_hash = weasyl.hash
WHERE weasyl.hash IN (SELECT hashes.found_hash) WHERE weasyl.hash IN (SELECT hashes.found_hash)
@ -149,6 +152,7 @@ pub async fn image_query(
hashes.searched_hash, hashes.searched_hash,
hashes.distance, hashes.distance,
null sha256 null sha256
null flags
FROM hashes FROM hashes
JOIN tweet_media ON hashes.found_hash = tweet_media.hash JOIN tweet_media ON hashes.found_hash = tweet_media.hash
JOIN tweet ON tweet_media.tweet_id = tweet.id JOIN tweet ON tweet_media.tweet_id = tweet.id
@ -164,6 +168,7 @@ pub async fn image_query(
}, },
Some("e621") => SiteInfo::E621 { Some("e621") => SiteInfo::E621 {
sources: row.sources, sources: row.sources,
flags: row.flags,
}, },
Some("Twitter") => SiteInfo::Twitter, Some("Twitter") => SiteInfo::Twitter,
Some("Weasyl") => SiteInfo::Weasyl, Some("Weasyl") => SiteInfo::Weasyl,

View File

@ -54,6 +54,16 @@ pub struct SearchResult {
pub searched_hash: Option<i64>, pub searched_hash: Option<i64>,
} }
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct E621Flags {
pending: bool,
flagged: bool,
note_locked: bool,
status_locked: bool,
rating_locked: bool,
deleted: bool,
}
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "site", content = "site_info")] #[serde(tag = "site", content = "site_info")]
pub enum SiteInfo { pub enum SiteInfo {
@ -63,6 +73,7 @@ pub enum SiteInfo {
#[serde(rename = "e621")] #[serde(rename = "e621")]
E621 { E621 {
sources: Option<Vec<String>>, sources: Option<Vec<String>>,
flags: Option<E621Flags>,
}, },
Twitter, Twitter,
Weasyl, Weasyl,