|
|
|
@ -108,6 +108,7 @@ type MisskeyStatus struct {
|
|
|
|
|
|
|
|
|
|
type AccountMisskey struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
Host string `json:"host"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
AvatarURL string `json:"avatarUrl"`
|
|
|
|
@ -257,7 +258,7 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
|
|
|
|
|
var publicstatuses []*Status
|
|
|
|
|
var instanceParams []string
|
|
|
|
|
instanceParams = strings.Split(instance, ":")[1:]
|
|
|
|
|
instance = strings.Split(instance, ":")[0]
|
|
|
|
|
instance = strings.TrimSpace(strings.Split(instance, ":")[0])
|
|
|
|
|
params := url.Values{}
|
|
|
|
|
params.Set("local", "true")
|
|
|
|
|
|
|
|
|
@ -268,18 +269,28 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
|
|
|
|
|
perform := url.URL{
|
|
|
|
|
Scheme: "https",
|
|
|
|
|
Host: instance,
|
|
|
|
|
RawQuery: params.Encode(),
|
|
|
|
|
}
|
|
|
|
|
var paramval []string
|
|
|
|
|
withFiles := "false"
|
|
|
|
|
withReplies := "false"
|
|
|
|
|
globalTimeline := false
|
|
|
|
|
for _, instanceParam := range instanceParams {
|
|
|
|
|
switch instanceParam {
|
|
|
|
|
case "withFiles":
|
|
|
|
|
withFiles = "true"
|
|
|
|
|
params.Set("only_media", "true")
|
|
|
|
|
case "withReplies":
|
|
|
|
|
withReplies = "true"
|
|
|
|
|
default:
|
|
|
|
|
case "remote":
|
|
|
|
|
globalTimeline = true
|
|
|
|
|
params.Set(instanceParam, "true")
|
|
|
|
|
default:
|
|
|
|
|
paramval = strings.Split(instanceParam, "=")
|
|
|
|
|
if len(paramval) == 2 {
|
|
|
|
|
params.Set(paramval[0], paramval[1])
|
|
|
|
|
} else {
|
|
|
|
|
params.Set(instanceParam, "true")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -288,7 +299,11 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
|
|
|
|
|
var bytesAttach []byte
|
|
|
|
|
switch instance_type {
|
|
|
|
|
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 = ""
|
|
|
|
|
method = http.MethodPost
|
|
|
|
|
ContentType = "application/json"
|
|
|
|
@ -303,6 +318,10 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
if globalTimeline {
|
|
|
|
|
params.Set("local", "false")
|
|
|
|
|
}
|
|
|
|
|
perform.RawQuery = params.Encode()
|
|
|
|
|
perform.Path = "api/v1/timelines/public"
|
|
|
|
|
method = http.MethodGet
|
|
|
|
|
ContentType = "application/x-www-form-urlencoded"
|
|
|
|
@ -335,7 +354,11 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
|
|
|
|
|
status.ID = statusMisskey.ID
|
|
|
|
|
status.Account.ID = statusMisskey.User.ID
|
|
|
|
|
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.Avatar = statusMisskey.User.AvatarURL
|
|
|
|
|
status.CreatedAt = statusMisskey.CreatedAt
|
|
|
|
@ -371,6 +394,14 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
|
|
|
|
|
status.URL = "https://" + instance + "/notes/" + statusMisskey.ID
|
|
|
|
|
publicstatuses = append(publicstatuses, &status)
|
|
|
|
|
}
|
|
|
|
|
case "friendica":
|
|
|
|
|
err = json.NewDecoder(resp.Body).Decode(&publicstatuses)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
for _, status := range publicstatuses {
|
|
|
|
|
status.URL = status.URI // Fix federate URL
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
err = json.NewDecoder(resp.Body).Decode(&publicstatuses)
|
|
|
|
|
if err != nil {
|
|
|
|
|