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 {
ID string `json:"id"`
Host string `json:"host"`
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatarUrl"`
@ -272,12 +273,17 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
}
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"
case "remote":
globalTimeline = true
params.Set(instanceParam, "true")
default:
params.Set(instanceParam, "true")
}
@ -288,7 +294,11 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
var bytesAttach []byte
switch instance_type {
case "misskey":
if globalTimeline {
perform.Path = "api/notes/global-timeline"
} else {
perform.Path = "api/notes/local-timeline"
}
perform.RawQuery = ""
method = http.MethodPost
ContentType = "application/json"
@ -335,7 +345,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
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 +385,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 {

View file

@ -26,10 +26,14 @@
<select id="instance_type" name="instance_type" title="Select instance type">
<option value="mastodon-compatible" default>Mastodon compatible</option>
<option value="misskey"{{if eq .InstanceType "misskey"}}selected{{end}}>Misskey</option>
<option value="friendica"{{if eq .InstanceType "friendica"}}selected{{end}}>Friendica</option>
</select>
</span>
<button type="submit"> Submit </button>
</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}}
{{if eq .Type "tag"}}
<form class="search-form" action="/timeline/tag" method="GET">