mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-28 23:52:25 -05:00
[feature] Enable federation in/out of profile PropertyValue fields (#1722)
Co-authored-by: kim <grufwub@gmail.com> Co-authored-by: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>
This commit is contained in:
parent
cbb9e2d3f0
commit
0e29f1f5bb
180 changed files with 9278 additions and 1550 deletions
|
|
@ -266,6 +266,59 @@ func ExtractSummary(i WithSummary) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func ExtractFields(i WithAttachment) []*gtsmodel.Field {
|
||||
attachmentProp := i.GetActivityStreamsAttachment()
|
||||
if attachmentProp == nil {
|
||||
// Nothing to do.
|
||||
return nil
|
||||
}
|
||||
|
||||
l := attachmentProp.Len()
|
||||
if l == 0 {
|
||||
// Nothing to do.
|
||||
return nil
|
||||
}
|
||||
|
||||
fields := make([]*gtsmodel.Field, 0, l)
|
||||
for iter := attachmentProp.Begin(); iter != attachmentProp.End(); iter = iter.Next() {
|
||||
if !iter.IsSchemaPropertyValue() {
|
||||
continue
|
||||
}
|
||||
|
||||
propertyValue := iter.GetSchemaPropertyValue()
|
||||
if propertyValue == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
nameProp := propertyValue.GetActivityStreamsName()
|
||||
if nameProp == nil || nameProp.Len() != 1 {
|
||||
continue
|
||||
}
|
||||
|
||||
name := nameProp.At(0).GetXMLSchemaString()
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
valueProp := propertyValue.GetSchemaValue()
|
||||
if valueProp == nil || !valueProp.IsXMLSchemaString() {
|
||||
continue
|
||||
}
|
||||
|
||||
value := valueProp.Get()
|
||||
if value == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
fields = append(fields, >smodel.Field{
|
||||
Name: name,
|
||||
Value: value,
|
||||
})
|
||||
}
|
||||
|
||||
return fields
|
||||
}
|
||||
|
||||
// ExtractDiscoverable extracts the Discoverable boolean of an interface.
|
||||
func ExtractDiscoverable(i WithDiscoverable) (bool, error) {
|
||||
if i.GetTootDiscoverable() == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue