1
0
Fork 0
forked from alemi/upub

fix: filter out empty targets

This commit is contained in:
əlemi 2024-03-27 04:36:46 +01:00
parent 625b8e0e02
commit 742c769014
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -153,7 +153,8 @@ impl Context {
pub async fn address_to(&self, aid: &str, oid: Option<&str>, targets: &[String]) -> Result<(), DbErr> { pub async fn address_to(&self, aid: &str, oid: Option<&str>, targets: &[String]) -> Result<(), DbErr> {
let addressings : Vec<model::addressing::ActiveModel> = targets let addressings : Vec<model::addressing::ActiveModel> = targets
.iter() .iter()
.filter(|x| !x.ends_with("/followers")) .filter(|to| !to.is_empty())
.filter(|to| !to.ends_with("/followers"))
.map(|to| model::addressing::ActiveModel { .map(|to| model::addressing::ActiveModel {
id: sea_orm::ActiveValue::NotSet, id: sea_orm::ActiveValue::NotSet,
server: Set(Context::server(to)), server: Set(Context::server(to)),
@ -176,6 +177,7 @@ impl Context {
pub async fn deliver_to(&self, aid: &str, from: &str, targets: &[String]) -> Result<(), DbErr> { pub async fn deliver_to(&self, aid: &str, from: &str, targets: &[String]) -> Result<(), DbErr> {
let deliveries : Vec<model::delivery::ActiveModel> = targets let deliveries : Vec<model::delivery::ActiveModel> = targets
.iter() .iter()
.filter(|to| !to.is_empty())
.filter(|to| Context::server(to) != self.base()) .filter(|to| Context::server(to) != self.base())
.filter(|to| to != &PUBLIC_TARGET) .filter(|to| to != &PUBLIC_TARGET)
.map(|to| model::delivery::ActiveModel { .map(|to| model::delivery::ActiveModel {