Federate posts without a double-line break as Notes

This proof-of-concept sends out posts that don't include a double-line
break as Notes -- otherwise they go out as Articles, as before.

Inspired by the discussion here:
https://socialhub.activitypub.rocks/t/resolving-the-note-vs-article-distinction/258
pull/220/head
Matt Baer 5 years ago
parent bd99044e9c
commit 5259c4fcdf
  1. 7
      posts.go

@ -1126,7 +1126,12 @@ func (p *PublicPost) CanonicalURL(hostName string) string {
}
func (p *PublicPost) ActivityObject(cfg *config.Config) *activitystreams.Object {
o := activitystreams.NewArticleObject()
var o *activitystreams.Object
if strings.Index(p.Content, "\n\n") == -1 {
o = activitystreams.NewNoteObject()
} else {
o = activitystreams.NewArticleObject()
}
o.ID = p.Collection.FederatedAPIBase() + "api/posts/" + p.ID
o.Published = p.Created
o.URL = p.CanonicalURL(cfg.App.Host)

Loading…
Cancel
Save