Skip to content

Commit

Permalink
feat(server): ✨ implement check for image mime types
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan6erbond committed May 14, 2023
1 parent afaf49d commit 1ba3108
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/pkg/tags/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ func RegisterCommands(app *pocketbase.PocketBase, taggerHost string) {
continue
}

var isImageType bool
for _, t := range imageMimeTypes {
if file.GetString("type") == t {
isImageType = true
continue
}
}

if !isImageType {
continue
}

url, err := url.Parse(taggerHost)

if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions server/pkg/tags/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ func RegisterHooks(app *pocketbase.PocketBase, taggerHost string) {
return nil
}

var isImageType bool
for _, t := range imageMimeTypes {
if e.Record.GetString("type") == t {
isImageType = true
continue
}
}

if !isImageType {
return nil
}

url, err := url.Parse(taggerHost)

if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions server/pkg/tags/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package tags

var imageMimeTypes = []string{"image/png", "image/gif", "image/jpeg", "image/svg+xml", "image/webp", "image/avif"}

0 comments on commit 1ba3108

Please sign in to comment.