Show follow request count on user page
This commit is contained in:
parent
11ea3b4d47
commit
6ad1c5436a
|
@ -40,6 +40,9 @@ type Account struct {
|
||||||
Bot bool `json:"bot"`
|
Bot bool `json:"bot"`
|
||||||
Source *AccountSource `json:"source"`
|
Source *AccountSource `json:"source"`
|
||||||
Pleroma *AccountPleroma `json:"pleroma"`
|
Pleroma *AccountPleroma `json:"pleroma"`
|
||||||
|
|
||||||
|
// Duplicate field for compatibilty with Pleroma
|
||||||
|
FollowRequestsCount int64 `json:"follow_requests_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field is a Mastodon account profile field.
|
// Field is a Mastodon account profile field.
|
||||||
|
@ -51,11 +54,12 @@ type Field struct {
|
||||||
|
|
||||||
// AccountSource is a Mastodon account profile field.
|
// AccountSource is a Mastodon account profile field.
|
||||||
type AccountSource struct {
|
type AccountSource struct {
|
||||||
Privacy *string `json:"privacy"`
|
Privacy *string `json:"privacy"`
|
||||||
Sensitive *bool `json:"sensitive"`
|
Sensitive *bool `json:"sensitive"`
|
||||||
Language *string `json:"language"`
|
Language *string `json:"language"`
|
||||||
Note *string `json:"note"`
|
Note *string `json:"note"`
|
||||||
Fields *[]Field `json:"fields"`
|
Fields *[]Field `json:"fields"`
|
||||||
|
FollowRequestsCount int64 `json:"follow_requests_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccount return Account.
|
// GetAccount return Account.
|
||||||
|
|
|
@ -511,12 +511,19 @@ func (s *service) UserPage(c *client, id string, pageType string,
|
||||||
MinID: minID,
|
MinID: minID,
|
||||||
Limit: 20,
|
Limit: 20,
|
||||||
}
|
}
|
||||||
|
isCurrent := c.s.UserID == id
|
||||||
|
|
||||||
user, err := c.GetAccount(c.ctx, id)
|
// Some fields like AccountSource are only available in the
|
||||||
|
// CurrentUser API
|
||||||
|
var user *mastodon.Account
|
||||||
|
if isCurrent {
|
||||||
|
user, err = c.GetAccountCurrentUser(c.ctx)
|
||||||
|
} else {
|
||||||
|
user, err = c.GetAccount(c.ctx, id)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isCurrent := c.s.UserID == user.ID
|
|
||||||
|
|
||||||
switch pageType {
|
switch pageType {
|
||||||
case "":
|
case "":
|
||||||
|
|
|
@ -110,7 +110,9 @@
|
||||||
- <a href="/user/{{.User.ID}}/likes">likes</a>
|
- <a href="/user/{{.User.ID}}/likes">likes</a>
|
||||||
- <a href="/user/{{.User.ID}}/mutes">mutes</a>
|
- <a href="/user/{{.User.ID}}/mutes">mutes</a>
|
||||||
- <a href="/user/{{.User.ID}}/blocks">blocks</a>
|
- <a href="/user/{{.User.ID}}/blocks">blocks</a>
|
||||||
{{if .User.Locked}}- <a href="/user/{{.User.ID}}/requests">requests</a>{{end}}
|
{{if .User.Locked}}- <a href="/user/{{.User.ID}}/requests">requests (
|
||||||
|
{{- if .User.FollowRequestsCount}}{{.User.FollowRequestsCount}}{{else}}{{.User.Source.FollowRequestsCount}}{{end -}}
|
||||||
|
)</a>{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in New Issue