Skip to content

Commit

Permalink
add mp4 link type (#9)
Browse files Browse the repository at this point in the history
Signed-off-by: Kathurima Kimathi <kathurimakimathi415@gmail.com>
  • Loading branch information
KathurimaKimathi committed Sep 7, 2021
1 parent 05465ee commit dcdc4ba
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/gitguardian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: GitGuardian scan

on: [push, pull_request]

jobs:
scanning:
name: GitGuardian scan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all history so multiple commits can be scanned
- name: GitGuardian scan
uses: GitGuardian/gg-shield-action@master
env:
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }}
GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}
GITHUB_PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
22 changes: 21 additions & 1 deletion engagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ func (l *Link) validateLinkType() error {
if !strings.Contains(l.URL, ".png") {
return fmt.Errorf("%s does not end with .pdf", l.URL)
}
case LinkTypeMp4:
if !strings.Contains(l.URL, ".mp4") {
return fmt.Errorf("%s does not end with .mp4", l.URL)
}
case LinkTypePngImage:
if !strings.Contains(l.URL, ".png") {
return fmt.Errorf("%s does not end with .png", l.URL)
Expand Down Expand Up @@ -722,6 +726,7 @@ const (
LinkTypePngImage LinkType = "PNG_IMAGE"
LinkTypePdfDocument LinkType = "PDF_DOCUMENT"
LinkTypeSvgImage LinkType = "SVG_IMAGE"
LinkTypeMp4 LinkType = "MP4"
LinkTypeDefault LinkType = "DEFAULT"
)

Expand All @@ -731,13 +736,14 @@ var AllLinkType = []LinkType{
LinkTypePngImage,
LinkTypePdfDocument,
LinkTypeSvgImage,
LinkTypeMp4,
LinkTypeDefault,
}

// IsValid is true only when a link type is avalid
func (e LinkType) IsValid() bool {
switch e {
case LinkTypeYoutubeVideo, LinkTypePngImage, LinkTypePdfDocument, LinkTypeSvgImage, LinkTypeDefault:
case LinkTypeYoutubeVideo, LinkTypePngImage, LinkTypePdfDocument, LinkTypeSvgImage, LinkTypeMp4, LinkTypeDefault:
return true
}
return false
Expand Down Expand Up @@ -1016,6 +1022,20 @@ func GetPDFDocumentLink(url string, title string, description string, thumbnailU
}
}

// GetMP4Link returns an initialized MP4 link.
//
// It is used in testing and default data generation.
func GetMP4Link(url string, title string, description string, thumbnailURL string) Link {
return Link{
ID: ksuid.New().String(),
URL: url,
LinkType: LinkTypeMp4,
Title: title,
Description: description,
Thumbnail: thumbnailURL,
}
}

// getSchemaURL serves JSON schema from this server and only falls back to a
// remote schema host when the local server cannot serve the JSON schema files.
// This has been done so as to reduce the impact of the network and DNS on the
Expand Down
5 changes: 5 additions & 0 deletions engagement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,11 @@ func TestLinkType_MarshalGQL(t *testing.T) {
e: feedlib.LinkTypeYoutubeVideo,
wantW: `"YOUTUBE_VIDEO"`,
},
{
name: "MP4",
e: feedlib.LinkTypeMp4,
wantW: `"MP4"`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
7 changes: 2 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,6 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/savannahghi/serverutils v0.0.2 h1:ZVRRdyRH47qlqZCiZ3FKOd8W4ufhtvHQLLZxAQZonqk=
github.com/savannahghi/serverutils v0.0.2/go.mod h1:sLX0El0i0DKN/9cUkB8xqm5cVMP79qCZvK60EzB7Pa4=
github.com/savannahghi/serverutils v0.0.3 h1:1gX/zD6tt4tAEpcQFyzXBUp70BvUiqmJpjADqjdvFwI=
github.com/savannahghi/serverutils v0.0.3/go.mod h1:3VCEJ8BTHf/DW3WFjLqV4SznzrXaul/As2RJ5eNOO7U=
github.com/savannahghi/serverutils v0.0.4 h1:mQGAwhNgS1NPSBXqCeyywuGQFnvRxiOmHJEHPgzhWQE=
github.com/savannahghi/serverutils v0.0.4/go.mod h1:3VCEJ8BTHf/DW3WFjLqV4SznzrXaul/As2RJ5eNOO7U=
github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g=
Expand All @@ -287,6 +283,7 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down Expand Up @@ -333,6 +330,7 @@ go.opentelemetry.io/otel v1.0.0-RC1 h1:4CeoX93DNTWt8awGK9JmNXzF9j7TyOu9upscEdtcd
go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I=
go.opentelemetry.io/otel/exporters/jaeger v1.0.0-RC1 h1:tVhw2BMSAk248rhdeirOe9hlXKwGHDvVtF7P8F+H2DU=
go.opentelemetry.io/otel/exporters/jaeger v1.0.0-RC1/go.mod h1:FXJnjGCoTQL6nQ8OpFJ0JI1DrdOvMoVx49ic0Hg4+D4=
go.opentelemetry.io/otel/oteltest v1.0.0-RC1 h1:G685iP3XiskCwk/z0eIabL55XUl2gk0cljhGk9sB0Yk=
go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4=
go.opentelemetry.io/otel/sdk v1.0.0-RC1 h1:Sy2VLOOg24bipyC29PhuMXYNJrLsxkie8hyI7kUlG9Q=
go.opentelemetry.io/otel/sdk v1.0.0-RC1/go.mod h1:kj6yPn7Pgt5ByRuwesbaWcRLA+V7BSDg3Hf8xRvsvf8=
Expand Down Expand Up @@ -705,7 +703,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down

0 comments on commit dcdc4ba

Please sign in to comment.