[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:
tobi 2023-05-09 12:16:10 +02:00 committed by GitHub
commit 0e29f1f5bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
180 changed files with 9278 additions and 1550 deletions

View file

@ -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, &gtsmodel.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 {