feat(ports): add get_thought_ap_id and get_actor_ap_urls to ActivityPubRepository
This commit is contained in:
@@ -10,7 +10,7 @@ use url::Url;
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
models::thought::{Thought, Visibility},
|
||||
ports::{ActivityPubRepository, OutboxEntry},
|
||||
ports::{ActivityPubRepository, ActorApUrls, OutboxEntry},
|
||||
value_objects::{Content, ThoughtId, UserId, Username},
|
||||
};
|
||||
|
||||
@@ -297,6 +297,34 @@ impl ActivityPubRepository for PgActivityPubRepository {
|
||||
.into_domain()?;
|
||||
Ok(n as u64)
|
||||
}
|
||||
|
||||
async fn get_thought_ap_id(
|
||||
&self,
|
||||
thought_id: &ThoughtId,
|
||||
) -> Result<Option<String>, DomainError> {
|
||||
sqlx::query_scalar::<_, String>(
|
||||
"SELECT ap_id FROM thoughts WHERE id = $1 AND ap_id IS NOT NULL",
|
||||
)
|
||||
.bind(thought_id.as_uuid())
|
||||
.fetch_optional(&self.pool)
|
||||
.await
|
||||
.into_domain()
|
||||
}
|
||||
|
||||
async fn get_actor_ap_urls(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
) -> Result<Option<ActorApUrls>, DomainError> {
|
||||
sqlx::query_as::<_, (String, String)>(
|
||||
"SELECT ap_id, inbox_url FROM users \
|
||||
WHERE id = $1 AND ap_id IS NOT NULL AND inbox_url IS NOT NULL",
|
||||
)
|
||||
.bind(user_id.as_uuid())
|
||||
.fetch_optional(&self.pool)
|
||||
.await
|
||||
.into_domain()
|
||||
.map(|opt| opt.map(|(ap_id, inbox_url)| ActorApUrls { ap_id, inbox_url }))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user