Compare commits

...

3 commits

2 changed files with 28 additions and 2 deletions

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
@ -371,6 +385,14 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
status.URL = "https://" + instance + "/notes/" + statusMisskey.ID status.URL = "https://" + instance + "/notes/" + statusMisskey.ID
publicstatuses = append(publicstatuses, &status) 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: default:
err = json.NewDecoder(resp.Body).Decode(&publicstatuses) err = json.NewDecoder(resp.Body).Decode(&publicstatuses)
if err != nil { if err != nil {

View file

@ -26,10 +26,14 @@
<select id="instance_type" name="instance_type" title="Select instance type"> <select id="instance_type" name="instance_type" title="Select instance type">
<option value="mastodon-compatible" default>Mastodon compatible</option> <option value="mastodon-compatible" default>Mastodon compatible</option>
<option value="misskey"{{if eq .InstanceType "misskey"}}selected{{end}}>Misskey</option> <option value="misskey"{{if eq .InstanceType "misskey"}}selected{{end}}>Misskey</option>
<option value="friendica"{{if eq .InstanceType "friendica"}}selected{{end}}>Friendica</option>
</select> </select>
</span> </span>
<button type="submit"> Submit </button> <button type="submit"> Submit </button>
</form> </form>
{{if eq .Instance ""}}
<span>Possible params:<br>withFiles - show posts only with media<br>remote - try fetch their global timeline<br>You can combine params: withFile:remote:some_other_param</span>
{{end}}
{{end}} {{end}}
{{if eq .Type "tag"}} {{if eq .Type "tag"}}
<form class="search-form" action="/timeline/tag" method="GET"> <form class="search-form" action="/timeline/tag" method="GET">