diff --git a/tiktok/content.go b/tiktok/content.go index e2b27b1..e615e61 100644 --- a/tiktok/content.go +++ b/tiktok/content.go @@ -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", diff --git a/tiktok/errors.go b/tiktok/errors.go new file mode 100644 index 0000000..5c19b0b --- /dev/null +++ b/tiktok/errors.go @@ -0,0 +1,7 @@ +package tiktok + +import "errors" + +var ( + PrivacyLevelWrong = errors.New("Privacy Level is not correct!") +) diff --git a/tiktok/privacy.go b/tiktok/privacy.go index 6a26f42..e30a209 100644 --- a/tiktok/privacy.go +++ b/tiktok/privacy.go @@ -10,4 +10,14 @@ const ( PUBLIC_TO_EVERYONE PrivacyLevelOptions = "PUBLIC_TO_EVERYONE" MUTUAL_FOLLOW_FRIENDS PrivacyLevelOptions = "MUTUAL_FOLLOW_FRIENDS" SELF_ONLY PrivacyLevelOptions = "SELF_ONLY" -) \ No newline at end of file +) + +// 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 + } +} \ No newline at end of file