true remote timeline params tweaks

This commit is contained in:
localhost_frssoft 2023-11-13 11:41:08 +03:00
parent fc43de6012
commit 18c37c0c2f

View file

@ -108,6 +108,7 @@ type MisskeyStatus struct {
type AccountMisskey struct { type AccountMisskey struct {
ID string `json:"id"` ID string `json:"id"`
Host string `json:"host"`
Name string `json:"name"` Name string `json:"name"`
Username string `json:"username"` Username string `json:"username"`
AvatarURL string `json:"avatarUrl"` AvatarURL string `json:"avatarUrl"`
@ -272,12 +273,17 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
} }
withFiles := "false" withFiles := "false"
withReplies := "false" withReplies := "false"
globalTimeline := false
for _, instanceParam := range instanceParams { for _, instanceParam := range instanceParams {
switch instanceParam { switch instanceParam {
case "withFiles": case "withFiles":
withFiles = "true" withFiles = "true"
params.Set("only_media", "true")
case "withReplies": case "withReplies":
withReplies = "true" withReplies = "true"
case "remote":
globalTimeline = true
params.Set(instanceParam, "true")
default: default:
params.Set(instanceParam, "true") params.Set(instanceParam, "true")
} }
@ -288,7 +294,11 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
var bytesAttach []byte var bytesAttach []byte
switch instance_type { switch instance_type {
case "misskey": case "misskey":
perform.Path = "api/notes/local-timeline" if globalTimeline {
perform.Path = "api/notes/global-timeline"
} else {
perform.Path = "api/notes/local-timeline"
}
perform.RawQuery = "" perform.RawQuery = ""
method = http.MethodPost method = http.MethodPost
ContentType = "application/json" ContentType = "application/json"
@ -335,7 +345,11 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
status.ID = statusMisskey.ID status.ID = statusMisskey.ID
status.Account.ID = statusMisskey.User.ID status.Account.ID = statusMisskey.User.ID
status.Account.DisplayName = statusMisskey.User.Name status.Account.DisplayName = statusMisskey.User.Name
status.Account.Acct = statusMisskey.User.Username if statusMisskey.User.Host != "" {
status.Account.Acct = statusMisskey.User.Username + "@" + statusMisskey.User.Host
} else {
status.Account.Acct = statusMisskey.User.Username
}
status.Account.Username = statusMisskey.User.Username status.Account.Username = statusMisskey.User.Username
status.Account.Avatar = statusMisskey.User.AvatarURL status.Account.Avatar = statusMisskey.User.AvatarURL
status.CreatedAt = statusMisskey.CreatedAt status.CreatedAt = statusMisskey.CreatedAt