add helper for special claim tags

This commit is contained in:
Niko Storni 2022-09-16 03:18:01 +02:00
parent 2adb8af5b6
commit 41555cbda2

View file

@ -7,6 +7,7 @@ import (
"net/http"
"os"
"reflect"
"strings"
"github.com/lbryio/lbry.go/v2/extras/errors"
"github.com/lbryio/lbry.go/v2/stream"
@ -425,6 +426,28 @@ func (c *Claim) GetStreamSizeByMagic() (streamSize uint64, e error) {
return streamSize, nil
}
const (
ProtectedContentTag = SpecialContentType("c:members-only")
PurchaseContentTag = SpecialContentType("c:purchase:")
RentalContentTag = SpecialContentType("c:rental:")
PreorderContentTag = SpecialContentType("c:preorder:")
LegacyPurchaseContentTag = SpecialContentType("purchase:")
LegacyRentalContentTag = SpecialContentType("rental:")
LegacyPreorderContentTag = SpecialContentType("preorder:")
)
type SpecialContentType string
//IsContentSpecial returns true if the claim is of a special content type
func (c *Claim) IsContentSpecial(specialTag SpecialContentType) bool {
for _, t := range c.Value.GetTags() {
if strings.Contains(t, string(specialTag)) {
return true
}
}
return false
}
type StreamListResponse struct {
Items []Claim `json:"items"`
Page uint64 `json:"page"`