Write values of actor tags to log

This commit is contained in:
silverpill 2023-01-07 20:33:23 +00:00
parent 44ce9a73a2
commit 65496e5260
2 changed files with 21 additions and 1 deletions

View file

@ -1,11 +1,12 @@
use std::path::Path; use std::path::Path;
use serde_json::{Value as JsonValue};
use tokio_postgres::GenericClient; use tokio_postgres::GenericClient;
use crate::activitypub::{ use crate::activitypub::{
actors::types::Actor, actors::types::Actor,
fetcher::fetchers::fetch_file, fetcher::fetchers::fetch_file,
receiver::HandlerError, receiver::{parse_property_value, HandlerError},
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::models::profiles::{ use crate::models::profiles::{
@ -56,6 +57,18 @@ async fn fetch_actor_images(
(maybe_avatar, maybe_banner) (maybe_avatar, maybe_banner)
} }
fn parse_tags(actor: &Actor) -> () {
if let Some(ref tag_list_value) = actor.tag {
let maybe_tag_list: Option<Vec<JsonValue>> =
parse_property_value(tag_list_value).ok();
if let Some(tag_list) = maybe_tag_list {
for tag_value in tag_list {
log::info!("found actor tag: {}", tag_value);
};
};
};
}
pub async fn create_remote_profile( pub async fn create_remote_profile(
db_client: &impl GenericClient, db_client: &impl GenericClient,
instance: &Instance, instance: &Instance,
@ -75,6 +88,7 @@ pub async fn create_remote_profile(
).await; ).await;
let (identity_proofs, payment_options, extra_fields) = let (identity_proofs, payment_options, extra_fields) =
actor.parse_attachments(); actor.parse_attachments();
parse_tags(&actor);
let mut profile_data = ProfileCreateData { let mut profile_data = ProfileCreateData {
username: actor.preferred_username.clone(), username: actor.preferred_username.clone(),
hostname: Some(actor_address.hostname), hostname: Some(actor_address.hostname),
@ -124,6 +138,7 @@ pub async fn update_remote_profile(
).await; ).await;
let (identity_proofs, payment_options, extra_fields) = let (identity_proofs, payment_options, extra_fields) =
actor.parse_attachments(); actor.parse_attachments();
parse_tags(&actor);
let mut profile_data = ProfileUpdateData { let mut profile_data = ProfileUpdateData {
display_name: actor.name.clone(), display_name: actor.name.clone(),
bio: actor.summary.clone(), bio: actor.summary.clone(),

View file

@ -151,6 +151,9 @@ pub struct Actor {
#[serde(default)] #[serde(default)]
pub manually_approves_followers: bool, pub manually_approves_followers: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub tag: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>, pub url: Option<String>,
} }
@ -333,6 +336,7 @@ pub fn get_local_actor(
also_known_as: None, also_known_as: None,
attachment: Some(attachments), attachment: Some(attachments),
manually_approves_followers: false, manually_approves_followers: false,
tag: None,
url: Some(actor_id), url: Some(actor_id),
}; };
Ok(actor) Ok(actor)
@ -371,6 +375,7 @@ pub fn get_instance_actor(
also_known_as: None, also_known_as: None,
attachment: None, attachment: None,
manually_approves_followers: false, manually_approves_followers: false,
tag: None,
url: None, url: None,
}; };
Ok(actor) Ok(actor)