(app *App)
| 1220 | } |
| 1221 | |
| 1222 | func (p *PublicPost) ActivityObject(app *App) *activitystreams.Object { |
| 1223 | cfg := app.cfg |
| 1224 | var o *activitystreams.Object |
| 1225 | if cfg.App.NotesOnly || strings.Index(p.Content, "\n\n") == -1 { |
| 1226 | o = activitystreams.NewNoteObject() |
| 1227 | } else { |
| 1228 | o = activitystreams.NewArticleObject() |
| 1229 | } |
| 1230 | o.ID = p.Collection.FederatedAPIBase() + "api/posts/" + p.ID |
| 1231 | o.Published = p.Created |
| 1232 | o.URL = p.CanonicalURL(cfg.App.Host) |
| 1233 | o.AttributedTo = p.Collection.FederatedAccount() |
| 1234 | o.CC = []string{ |
| 1235 | p.Collection.FederatedAccount() + "/followers", |
| 1236 | } |
| 1237 | o.Name = p.DisplayTitle() |
| 1238 | p.augmentContent() |
| 1239 | if p.HTMLContent == template.HTML("") { |
| 1240 | p.formatContent(cfg, false, false) |
| 1241 | p.augmentReadingDestination() |
| 1242 | } |
| 1243 | o.Content = string(p.HTMLContent) |
| 1244 | if p.Language.Valid { |
| 1245 | o.ContentMap = map[string]string{ |
| 1246 | p.Language.String: string(p.HTMLContent), |
| 1247 | } |
| 1248 | } |
| 1249 | if len(p.Tags) == 0 { |
| 1250 | o.Tag = []activitystreams.Tag{} |
| 1251 | } else { |
| 1252 | var tagBaseURL string |
| 1253 | if isSingleUser { |
| 1254 | tagBaseURL = p.Collection.CanonicalURL() + "tag:" |
| 1255 | } else { |
| 1256 | if cfg.App.Chorus { |
| 1257 | tagBaseURL = fmt.Sprintf("%s/read/t/", p.Collection.hostName) |
| 1258 | } else { |
| 1259 | tagBaseURL = fmt.Sprintf("%s/%s/tag:", p.Collection.hostName, p.Collection.Alias) |
| 1260 | } |
| 1261 | } |
| 1262 | for _, t := range p.Tags { |
| 1263 | o.Tag = append(o.Tag, activitystreams.Tag{ |
| 1264 | Type: activitystreams.TagHashtag, |
| 1265 | HRef: tagBaseURL + t, |
| 1266 | Name: "#" + t, |
| 1267 | }) |
| 1268 | } |
| 1269 | } |
| 1270 | if len(p.Images) > 0 { |
| 1271 | for _, i := range p.Images { |
| 1272 | o.Attachment = append(o.Attachment, activitystreams.NewImageAttachment(i)) |
| 1273 | } |
| 1274 | } |
| 1275 | // Find mentioned users |
| 1276 | mentionedUsers := make(map[string]string) |
| 1277 | |
| 1278 | stripper := bluemonday.StrictPolicy() |
| 1279 | content := stripper.Sanitize(p.Content) |
no test coverage detected