feat: 增加 bulesky 和 youtube 特定发布配置
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
cff74a8319
commit
2750c60bba
@ -140,6 +140,38 @@ func (a *AyrshareProvider) Post(_ context.Context, req *aryshare.PostRequest) (r
|
||||
dtoReq.TikTokOptions = tikTokOpts
|
||||
}
|
||||
|
||||
// 转换 YouTubeOptions
|
||||
if req.YouTubeOptions != nil {
|
||||
youTubeOpts := &dto.YouTubeOptions{
|
||||
Title: req.YouTubeOptions.Title,
|
||||
Description: req.YouTubeOptions.Description,
|
||||
Privacy: req.YouTubeOptions.Privacy,
|
||||
Tags: req.YouTubeOptions.Tags,
|
||||
CategoryId: req.YouTubeOptions.CategoryId,
|
||||
ThumbNail: req.YouTubeOptions.ThumbNail,
|
||||
PlaylistId: req.YouTubeOptions.PlaylistId,
|
||||
}
|
||||
if req.YouTubeOptions.MadeForKids {
|
||||
youTubeOpts.MadeForKids = &req.YouTubeOptions.MadeForKids
|
||||
}
|
||||
if req.YouTubeOptions.NotifySubscribers {
|
||||
youTubeOpts.NotifySubscribers = &req.YouTubeOptions.NotifySubscribers
|
||||
}
|
||||
dtoReq.YouTubeOptions = youTubeOpts
|
||||
}
|
||||
|
||||
// 转换 BlueskyOptions
|
||||
if req.BlueskyOptions != nil {
|
||||
blueskyOpts := &dto.BlueskyOptions{
|
||||
Labels: req.BlueskyOptions.Labels,
|
||||
Langs: req.BlueskyOptions.Langs,
|
||||
QuotedPostUri: req.BlueskyOptions.QuotedPostUri,
|
||||
ReplyToPostUri: req.BlueskyOptions.ReplyToPostUri,
|
||||
ReplyToPostCid: req.BlueskyOptions.ReplyToPostCid,
|
||||
}
|
||||
dtoReq.BlueskyOptions = blueskyOpts
|
||||
}
|
||||
|
||||
// 调用 logic 层
|
||||
dtoRes, err := a.arysharePostLogic.Post(dtoReq)
|
||||
if err != nil {
|
||||
|
||||
@ -113,6 +113,26 @@ type TikTokOptions struct {
|
||||
Visibility string `json:"visibility,omitempty"`
|
||||
}
|
||||
|
||||
type YouTubeOptions struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Privacy string `json:"privacy,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
CategoryId string `json:"categoryId,omitempty"`
|
||||
MadeForKids *bool `json:"madeForKids,omitempty"`
|
||||
ThumbNail string `json:"thumbNail,omitempty"`
|
||||
PlaylistId string `json:"playlistId,omitempty"`
|
||||
NotifySubscribers *bool `json:"notifySubscribers,omitempty"`
|
||||
}
|
||||
|
||||
type BlueskyOptions struct {
|
||||
Labels []string `json:"labels,omitempty"`
|
||||
Langs []string `json:"langs,omitempty"`
|
||||
QuotedPostUri string `json:"quotedPostUri,omitempty"`
|
||||
ReplyToPostUri string `json:"replyToPostUri,omitempty"`
|
||||
ReplyToPostCid string `json:"replyToPostCid,omitempty"`
|
||||
}
|
||||
|
||||
type PostRequest struct {
|
||||
Post string `json:"post"`
|
||||
Platforms []string `json:"platforms"`
|
||||
@ -124,6 +144,8 @@ type PostRequest struct {
|
||||
DisableComments *bool `json:"disableComments,omitempty"`
|
||||
InstagramOptions *InstagramOptions `json:"instagramOptions,omitempty"`
|
||||
TikTokOptions *TikTokOptions `json:"tikTokOptions,omitempty"`
|
||||
YouTubeOptions *YouTubeOptions `json:"youTubeOptions,omitempty"`
|
||||
BlueskyOptions *BlueskyOptions `json:"blueskyOptions,omitempty"`
|
||||
ProfileKey string `json:"-"`
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -7,8 +7,8 @@ import (
|
||||
fmt "fmt"
|
||||
math "math"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||
_ "github.com/mwitkow/go-proto-validators"
|
||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
|
||||
)
|
||||
|
||||
@ -33,6 +33,12 @@ func (this *InstagramOptions) Validate() error {
|
||||
func (this *TikTokOptions) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *YouTubeOptions) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *BlueskyOptions) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *PostRequest) Validate() error {
|
||||
if this.Post == "" {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Post", fmt.Errorf(`post内容不能为空`))
|
||||
@ -55,6 +61,16 @@ func (this *PostRequest) Validate() error {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("TikTokOptions", err)
|
||||
}
|
||||
}
|
||||
if this.YouTubeOptions != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.YouTubeOptions); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("YouTubeOptions", err)
|
||||
}
|
||||
}
|
||||
if this.BlueskyOptions != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.BlueskyOptions); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("BlueskyOptions", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *PostId) Validate() error {
|
||||
|
||||
@ -85,6 +85,28 @@ message TikTokOptions {
|
||||
string visibility = 13 [json_name = "visibility"]; // How the post is shared: "public", "private", "followers", "friends" (image only, default "public")
|
||||
}
|
||||
|
||||
// YouTube 特定发布选项
|
||||
message YouTubeOptions {
|
||||
string title = 1 [json_name = "title"]; // Video title (required for YouTube)
|
||||
string description = 2 [json_name = "description"]; // Video description
|
||||
string privacy = 3 [json_name = "privacy"]; // Privacy status: "public", "unlisted", "private" (default "public")
|
||||
repeated string tags = 4 [json_name = "tags"]; // Video tags
|
||||
string categoryId = 5 [json_name = "categoryId"]; // YouTube category ID
|
||||
bool madeForKids = 6 [json_name = "madeForKids"]; // Whether the video is made for kids
|
||||
string thumbNail = 7 [json_name = "thumbNail"]; // URL of custom thumbnail image
|
||||
string playlistId = 8 [json_name = "playlistId"]; // Playlist ID to add the video to
|
||||
bool notifySubscribers = 9 [json_name = "notifySubscribers"]; // Whether to notify subscribers (default true)
|
||||
}
|
||||
|
||||
// Bluesky 特定发布选项
|
||||
message BlueskyOptions {
|
||||
repeated string labels = 1 [json_name = "labels"]; // Content labels for the post
|
||||
repeated string langs = 2 [json_name = "langs"]; // Language codes (e.g., ["en", "zh"])
|
||||
string quotedPostUri = 3 [json_name = "quotedPostUri"]; // URI of the post to quote
|
||||
string replyToPostUri = 4 [json_name = "replyToPostUri"]; // URI of the post to reply to
|
||||
string replyToPostCid = 5 [json_name = "replyToPostCid"]; // CID of the post to reply to
|
||||
}
|
||||
|
||||
// 发布帖子到社交媒体平台
|
||||
message PostRequest {
|
||||
string post = 1 [json_name = "post", (validator.field) = {string_not_empty: true, human_error: "post内容不能为空"}];
|
||||
@ -98,6 +120,8 @@ message PostRequest {
|
||||
InstagramOptions instagramOptions = 9 [json_name = "instagramOptions"];
|
||||
TikTokOptions tikTokOptions = 10 [json_name = "tikTokOptions"];
|
||||
string profileKey = 11 [json_name = "profileKey"];
|
||||
YouTubeOptions youTubeOptions = 12 [json_name = "youTubeOptions"];
|
||||
BlueskyOptions blueskyOptions = 13 [json_name = "blueskyOptions"];
|
||||
}
|
||||
|
||||
// 单个平台的帖子ID响应
|
||||
|
||||
Loading…
Reference in New Issue
Block a user