Skip to content
This repository has been archived by the owner on Apr 23, 2022. It is now read-only.

Commit

Permalink
generate ShortID for Tracks and Videos
Browse files Browse the repository at this point in the history
  • Loading branch information
aureleoules committed Apr 7, 2019
1 parent a6019d6 commit 0c2df7c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion handlers/admin/tracks.go
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/backpulse/core/models"
"github.com/backpulse/core/utils"
"github.com/gorilla/mux"
"github.com/teris-io/shortid"
"gopkg.in/mgo.v2/bson"
)

Expand Down Expand Up @@ -54,7 +55,7 @@ func AddTrack(w http.ResponseWriter, r *http.Request) {

track.SiteID = site.ID
track.OwnerID = site.OwnerID

track.ShortID, _ = shortid.Generate()
track.ID = bson.NewObjectId()

tracks, _ := database.GetAlbumTracks(track.AlbumID)
Expand Down
3 changes: 2 additions & 1 deletion handlers/admin/videos.go
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/backpulse/core/models"
"github.com/backpulse/core/utils"
"github.com/gorilla/mux"
"github.com/teris-io/shortid"
"gopkg.in/mgo.v2/bson"
)

Expand Down Expand Up @@ -65,7 +66,7 @@ func AddVideo(w http.ResponseWriter, r *http.Request) {

video.SiteID = site.ID
video.OwnerID = site.OwnerID

video.ShortID, _ = shortid.Generate()
video.ID = bson.NewObjectId()

videos, _ := database.GetGroupVideos(video.VideoGroupID)
Expand Down
3 changes: 2 additions & 1 deletion models/Video.go
Expand Up @@ -8,7 +8,8 @@ import (

// Video struct
type Video struct {
ID bson.ObjectId `json:"id" bson:"_id"`
ID bson.ObjectId `json:"id" bson:"_id"`
ShortID string `json:"short_id" bson:"short_id"`

OwnerID bson.ObjectId `json:"owner_id" bson:"owner_id"`
SiteID bson.ObjectId `json:"site_id" bson:"site_id"`
Expand Down

0 comments on commit 0c2df7c

Please sign in to comment.