Skip to content

Commit

Permalink
added privacyLevel stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Jul 26, 2024
1 parent 23006f7 commit f8b0b58
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tiktok/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ curl --location 'https://open.tiktokapis.com/v2/post/publish/video/init/' \
}'
*/
func (o *tiktok) PostVideoInit(title, videoUrl string, privacyLevel string) (*PublishVideoResponse, error) {
if !CheckPrivacyLevel(privacyLevel){
return nil, PrivacyLevelWrong
}

request := &PublishVideoRequest{
PostInfo: PostInfo{
Title: title,
PrivacyLevel: privacyLevel,
},
SourceInfo: SourceInfo{
Source: "PULL_FROM_URL",
Expand Down
7 changes: 7 additions & 0 deletions tiktok/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package tiktok

import "errors"

var (
PrivacyLevelWrong = errors.New("Privacy Level is not correct!")
)
12 changes: 11 additions & 1 deletion tiktok/privacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ const (
PUBLIC_TO_EVERYONE PrivacyLevelOptions = "PUBLIC_TO_EVERYONE"
MUTUAL_FOLLOW_FRIENDS PrivacyLevelOptions = "MUTUAL_FOLLOW_FRIENDS"
SELF_ONLY PrivacyLevelOptions = "SELF_ONLY"
)
)

// CheckPrivacyLevel checks if the given string matches any PrivacyLevelOptions
func CheckPrivacyLevel(level string) bool {
switch PrivacyLevelOptions(level) {
case PUBLIC_TO_EVERYONE, MUTUAL_FOLLOW_FRIENDS, SELF_ONLY:
return true
default:
return false
}
}

0 comments on commit f8b0b58

Please sign in to comment.