diff --git a/ent/status.go b/ent/status.go index aa5c0c6..b40d988 100644 --- a/ent/status.go +++ b/ent/status.go @@ -183,7 +183,20 @@ func (receiver *Status) MarshalJSON() ([]byte, error) { //@TODO: Mentions -//@TODO: Tags + { + vals := receiver.Tags + if 0 < len(vals) { + const name = "tags" + p = append(p, `,"tags":`...) + + bytes, err := json.Marshal(vals) + if nil != err { + return nil, erorr.Errorf("problem marshaling %q: %w", name, err) + } + + p = append(p, bytes...) + } + } //@TODO: Emojis diff --git a/ent/status_marshaljson_test.go b/ent/status_marshaljson_test.go index 91761ef..cdbf05b 100644 --- a/ent/status_marshaljson_test.go +++ b/ent/status_marshaljson_test.go @@ -77,7 +77,24 @@ func TestStatus_JSON(t *testing.T) { //@TODO: MediaAttachments //@TODO: Application //@TODO: Mentions -//@TODO: Tags + + { + Status:Status{ + ID: opt.Something("123"), + Tags: []Tag{ + Tag{ + Name:opt.Something("akkoma"), + URL:opt.Something("https://example.com/tags/akkoma"), + }, + Tag{ + Name:opt.Something("fediverse"), + URL:opt.Something("https://example.com/tags/fediverse"), + }, + }, + }, + Expected: `{"id":"123","tags":[{"name":"akkoma","url":"https://example.com/tags/akkoma"},{"name":"fediverse","url":"https://example.com/tags/fediverse"}]}`, + }, + //@TODO: Emojis @@ -173,7 +190,7 @@ func TestStatus_JSON(t *testing.T) { t.Logf("ACTUAL: %q", actual) t.Logf("EXPECTED:\n%s", expected) t.Logf("ACTUAL:\n%s", actual) - t.Logf("STATUS:\n%v", test.Status) + t.Logf("STATUS:\n%#v", test.Status) continue } }