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:
parent
b801c1143e
commit
b3184e7ae2
1 changed files with 31 additions and 28 deletions
|
@ -124,13 +124,15 @@ impl Normalizer for crate::Context {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
for tag in object.tag() {
|
for tag in object.tag().flat() {
|
||||||
match tag.link_type() {
|
match tag {
|
||||||
|
Node::Empty | Node::Object(_) | Node::Array(_) => {},
|
||||||
|
Node::Link(l) => match l.link_type() {
|
||||||
Ok(apb::LinkType::Mention) => {
|
Ok(apb::LinkType::Mention) => {
|
||||||
let model = crate::model::mention::ActiveModel {
|
let model = crate::model::mention::ActiveModel {
|
||||||
internal: NotSet,
|
internal: NotSet,
|
||||||
object: Set(object_model.internal),
|
object: Set(object_model.internal),
|
||||||
actor: Set(tag.href().to_string()),
|
actor: Set(l.href().to_string()),
|
||||||
published: Set(now),
|
published: Set(now),
|
||||||
};
|
};
|
||||||
crate::model::mention::Entity::insert(model)
|
crate::model::mention::Entity::insert(model)
|
||||||
|
@ -138,8 +140,8 @@ impl Normalizer for crate::Context {
|
||||||
.await?;
|
.await?;
|
||||||
},
|
},
|
||||||
Ok(apb::LinkType::Hashtag) => {
|
Ok(apb::LinkType::Hashtag) => {
|
||||||
let hashtag = tag.name()
|
let hashtag = l.name()
|
||||||
.unwrap_or_else(|_| tag.href().split('/').last().unwrap_or_default())
|
.unwrap_or_else(|_| l.href().split('/').last().unwrap_or_default())
|
||||||
.replace('#', "");
|
.replace('#', "");
|
||||||
let model = crate::model::hashtag::ActiveModel {
|
let model = crate::model::hashtag::ActiveModel {
|
||||||
internal: NotSet,
|
internal: NotSet,
|
||||||
|
@ -154,6 +156,7 @@ impl Normalizer for crate::Context {
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(object_model)
|
Ok(object_model)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue