Commit f8e9eb3d authored by Lukas Matt's avatar Lukas Matt

Add signature order to like and comment directly

parent 0d1da01d
......@@ -20,8 +20,6 @@ package federation
import (
"errors"
"encoding/xml"
"reflect"
"strings"
)
type Message struct {
......@@ -51,24 +49,6 @@ type Entity struct {
Data interface{} `xml:"-"`
}
func (e *Entity) LocalSignatureOrder() (order string) {
val := reflect.TypeOf(e.Data)
for i := 0; i < val.NumField(); i++ {
params := strings.Split(val.Field(i).Tag.Get("xml"), ",")
if len(params) > 0 {
switch tagName := params[0]; tagName {
case "":
case "-":
case "author_signature":
case "parent_author_signature":
default:
order += params[0] + " "
}
}
}
return order[:len(order)-1] // trim space
}
func (e *Entity) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// NOTE since the encoder ignores the interface type
// (see https://golang.org/src/encoding/xml/read.go#L377)
......
......@@ -22,10 +22,14 @@ import "encoding/xml"
type EntityComment struct {
XMLName xml.Name `xml:"comment"`
Author string `xml:"author"`
CreatedAt string `xml:"created_at"`
Guid string `xml:"guid"`
ParentGuid string `xml:"parent_guid"`
Text string `xml:"text"`
AuthorSignature string `xml:"author_signature"`
ParentAuthorSignature string `xml:"parent_author_signature"`
SignatureOrder string `xml:"-"`
}
func (e *EntityComment) SignatureOrder() string {
return "author created_at guid parent_guid text"
}
......@@ -29,3 +29,7 @@ type EntityLike struct {
AuthorSignature string `xml:"author_signature"`
ParentAuthorSignature string `xml:"parent_author_signature"`
}
func (e *EntityLike) SignatureOrder() string {
return "positive guid parent_guid target_type author"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment