diff options
Diffstat (limited to 'activitypub/util.go')
-rw-r--r-- | activitypub/util.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activitypub/util.go b/activitypub/util.go index 7aee666..9dfa1ae 100644 --- a/activitypub/util.go +++ b/activitypub/util.go @@ -19,6 +19,18 @@ import ( // False positive for application/ld+ld, application/activity+ld, application/json+json var activityRegexp = regexp.MustCompile("application\\/(ld|json|activity)((\\+(ld|json))|$)") +func AcceptActivity(header string) bool { + accept := false + if strings.Contains(header, ";") { + split := strings.Split(header, ";") + accept = accept || activityRegexp.MatchString(split[0]) + accept = accept || strings.Contains(split[len(split)-1], "profile=\"https://www.w3.org/ns/activitystreams\"") + } else { + accept = accept || activityRegexp.MatchString(header) + } + return accept +} + func CreateAttachmentObject(file multipart.File, header *multipart.FileHeader) ([]ObjectBase, *os.File, error) { contentType, err := util.GetFileContentType(file) if err != nil { |