aboutsummaryrefslogtreecommitdiff
path: root/models/activity_streams_object.go
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2022-12-30 03:32:16 +0000
committerJulio Capote <jcapote@gmail.com>2022-12-30 03:32:16 +0000
commit74ffcfe6b2c80b7cf459798dc42bd278075ccb50 (patch)
tree231880fb4de3cf900d03c33531d2afc9603432d3 /models/activity_streams_object.go
parenta4288b06bf13210721c8f2fae64bc12c118f9041 (diff)
downloadcommunique-74ffcfe6b2c80b7cf459798dc42bd278075ccb50.tar.gz
experiment with write JSON to database and munge it for collections
Diffstat (limited to 'models/activity_streams_object.go')
-rw-r--r--models/activity_streams_object.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/models/activity_streams_object.go b/models/activity_streams_object.go
index 85a7d09..98c69bb 100644
--- a/models/activity_streams_object.go
+++ b/models/activity_streams_object.go
@@ -1,6 +1,8 @@
package models
import (
+ "bytes"
+ "encoding/json"
"fmt"
"time"
@@ -37,17 +39,16 @@ func (a *ActivityStreamsObject) Keybase() string {
}
func (a *ActivityStreamsObject) content() []byte {
- var contentVal string
- if a.wrappedObject.GetActivityStreamsContent() != nil {
- content := a.wrappedObject.GetActivityStreamsContent()
- for contentIter := content.Begin(); contentIter != content.End(); contentIter = contentIter.Next() {
- contentVal = contentIter.GetXMLSchemaString()
- }
- }
- return []byte(contentVal)
+ objMap, _ := a.wrappedObject.Serialize()
+ buffer := &bytes.Buffer{}
+ encoder := json.NewEncoder(buffer)
+ encoder.SetEscapeHTML(false)
+ encoder.Encode(objMap)
+ return bytes.TrimRight(buffer.Bytes(), "\n")
}
func (a *ActivityStreamsObject) Save(txn *badger.Txn) error {
- e := badger.NewEntry(a.keyName(), a.content())
+ content := a.content()
+ e := badger.NewEntry(a.keyName(), content)
return txn.SetEntry(e)
}