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
This commit is contained in:
Matt Baer 2019-12-04 19:40:52 -05:00
parent bd99044e9c
commit 5259c4fcdf

View file

@ -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)