fix: purchase ui
This commit is contained in:
@@ -173,6 +173,12 @@ func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *model.Users) (*PlayUrl, er
|
||||
// Url: "https://github.com/mediaelement/mediaelement-files/raw/refs/heads/master/big_buck_bunny.mp4",
|
||||
// }, nil
|
||||
|
||||
preview := false
|
||||
bought, err := models.Users.HasBought(ctx.Context(), user.ID, id)
|
||||
if !bought || err != nil {
|
||||
preview = true
|
||||
}
|
||||
|
||||
log.Infof("Fetching play URL for post ID: %d", id)
|
||||
post, err := models.Posts.GetByID(ctx.Context(), id)
|
||||
if err != nil {
|
||||
@@ -181,12 +187,6 @@ func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *model.Users) (*PlayUrl, er
|
||||
}
|
||||
go models.Posts.IncrViewCount(ctx.Context(), post.ID)
|
||||
|
||||
preview := false
|
||||
bought, err := models.Users.HasBought(ctx.Context(), user.ID, post.ID)
|
||||
if !bought || err != nil {
|
||||
preview = true
|
||||
}
|
||||
|
||||
for _, asset := range post.Assets.Data {
|
||||
if asset.Type == "video/mp4" && asset.Metas != nil && asset.Metas.Short == preview {
|
||||
media, err := models.Medias.GetByID(ctx.Context(), asset.Media)
|
||||
|
||||
Reference in New Issue
Block a user