1
0
Fork 0
forked from alemi/upub

fix: iter after flat and unpack node

flat iter gives us only objects, but we want links...
This commit is contained in:
əlemi 2024-06-22 05:08:05 +02:00
parent b801c1143e
commit b3184e7ae2
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -124,34 +124,37 @@ impl Normalizer for crate::Context {
.await?; .await?;
} }
for tag in object.tag() { for tag in object.tag().flat() {
match tag.link_type() { match tag {
Ok(apb::LinkType::Mention) => { Node::Empty | Node::Object(_) | Node::Array(_) => {},
let model = crate::model::mention::ActiveModel { Node::Link(l) => match l.link_type() {
internal: NotSet, Ok(apb::LinkType::Mention) => {
object: Set(object_model.internal), let model = crate::model::mention::ActiveModel {
actor: Set(tag.href().to_string()), internal: NotSet,
published: Set(now), object: Set(object_model.internal),
}; actor: Set(l.href().to_string()),
crate::model::mention::Entity::insert(model) published: Set(now),
.exec(tx) };
.await?; crate::model::mention::Entity::insert(model)
}, .exec(tx)
Ok(apb::LinkType::Hashtag) => { .await?;
let hashtag = tag.name() },
.unwrap_or_else(|_| tag.href().split('/').last().unwrap_or_default()) Ok(apb::LinkType::Hashtag) => {
.replace('#', ""); let hashtag = l.name()
let model = crate::model::hashtag::ActiveModel { .unwrap_or_else(|_| l.href().split('/').last().unwrap_or_default())
internal: NotSet, .replace('#', "");
object: Set(object_model.internal), let model = crate::model::hashtag::ActiveModel {
name: Set(hashtag), internal: NotSet,
published: Set(now), object: Set(object_model.internal),
}; name: Set(hashtag),
crate::model::hashtag::Entity::insert(model) published: Set(now),
.exec(tx) };
.await?; crate::model::hashtag::Entity::insert(model)
}, .exec(tx)
_ => {}, .await?;
},
_ => {},
}
} }
} }