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,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?;
|
||||||
|
},
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue