fix: update poster_url on remote review Update activity
All checks were successful
CI / Check / Test (push) Successful in 21m35s
All checks were successful
CI / Check / Test (push) Successful in 21m35s
on_update was ignoring posterUrl from the AP note, so remote instances never got the poster even after receiving the Update.
This commit is contained in:
@@ -23,6 +23,7 @@ pub trait RemoteReviewRepository: Send + Sync {
|
|||||||
rating: u8,
|
rating: u8,
|
||||||
comment: Option<&str>,
|
comment: Option<&str>,
|
||||||
watched_at: NaiveDateTime,
|
watched_at: NaiveDateTime,
|
||||||
|
poster_url: Option<&str>,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
async fn delete_by_actor(&self, actor_url: &str) -> Result<()>;
|
async fn delete_by_actor(&self, actor_url: &str) -> Result<()>;
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ impl ApObjectHandler for ReviewObjectHandler {
|
|||||||
obj.rating.min(5),
|
obj.rating.min(5),
|
||||||
obj.comment.as_deref(),
|
obj.comment.as_deref(),
|
||||||
obj.watched_at.naive_utc(),
|
obj.watched_at.naive_utc(),
|
||||||
|
obj.poster_url.as_deref(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -685,6 +685,7 @@ impl RemoteReviewRepository for PostgresFederationRepository {
|
|||||||
rating: u8,
|
rating: u8,
|
||||||
comment: Option<&str>,
|
comment: Option<&str>,
|
||||||
watched_at: chrono::NaiveDateTime,
|
watched_at: chrono::NaiveDateTime,
|
||||||
|
poster_url: Option<&str>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let watched_at_str = datetime_to_str(&watched_at);
|
let watched_at_str = datetime_to_str(&watched_at);
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
@@ -698,6 +699,17 @@ impl RemoteReviewRepository for PostgresFederationRepository {
|
|||||||
.bind(actor_url)
|
.bind(actor_url)
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
if let Some(url) = poster_url {
|
||||||
|
sqlx::query(
|
||||||
|
"UPDATE movies SET poster_path = $1
|
||||||
|
WHERE id = (SELECT movie_id FROM reviews WHERE ap_id = $2 AND remote_actor_url = $3)",
|
||||||
|
)
|
||||||
|
.bind(url)
|
||||||
|
.bind(ap_id)
|
||||||
|
.bind(actor_url)
|
||||||
|
.execute(&self.pool)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -870,6 +870,7 @@ impl RemoteReviewRepository for SqliteFederationRepository {
|
|||||||
rating: u8,
|
rating: u8,
|
||||||
comment: Option<&str>,
|
comment: Option<&str>,
|
||||||
watched_at: chrono::NaiveDateTime,
|
watched_at: chrono::NaiveDateTime,
|
||||||
|
poster_url: Option<&str>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let watched_at_str = datetime_to_str(&watched_at);
|
let watched_at_str = datetime_to_str(&watched_at);
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
@@ -883,6 +884,17 @@ impl RemoteReviewRepository for SqliteFederationRepository {
|
|||||||
.bind(actor_url)
|
.bind(actor_url)
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
if let Some(url) = poster_url {
|
||||||
|
sqlx::query(
|
||||||
|
"UPDATE movies SET poster_path = ?
|
||||||
|
WHERE id = (SELECT movie_id FROM reviews WHERE ap_id = ? AND remote_actor_url = ?)",
|
||||||
|
)
|
||||||
|
.bind(url)
|
||||||
|
.bind(ap_id)
|
||||||
|
.bind(actor_url)
|
||||||
|
.execute(&self.pool)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user