mirror of
https://git.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-22 12:01:27 +00:00
Add account {hide,show}retweets
This commit is contained in:
parent
04af1b93dc
commit
91d87b0175
|
@ -199,9 +199,13 @@ type Relationship struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountFollow follow the account.
|
// AccountFollow follow the account.
|
||||||
func (c *Client) AccountFollow(ctx context.Context, id string) (*Relationship, error) {
|
func (c *Client) AccountFollow(ctx context.Context, id string, reblogs *bool) (*Relationship, error) {
|
||||||
var relationship Relationship
|
var relationship Relationship
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/follow", url.PathEscape(string(id))), nil, &relationship, nil)
|
params := url.Values{}
|
||||||
|
if reblogs != nil {
|
||||||
|
params.Set("reblogs", strconv.FormatBool(*reblogs))
|
||||||
|
}
|
||||||
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/follow", url.PathEscape(id)), params, &relationship, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ func (s *as) Vote(ctx context.Context, c *model.Client, id string,
|
||||||
return s.Service.Vote(ctx, c, id, choices)
|
return s.Service.Vote(ctx, c, id, choices)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *as) Follow(ctx context.Context, c *model.Client, id string) (err error) {
|
func (s *as) Follow(ctx context.Context, c *model.Client, id string, reblogs *bool) (err error) {
|
||||||
err = s.authenticateClient(ctx, c)
|
err = s.authenticateClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -301,7 +301,7 @@ func (s *as) Follow(ctx context.Context, c *model.Client, id string) (err error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return s.Service.Follow(ctx, c, id)
|
return s.Service.Follow(ctx, c, id, reblogs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *as) UnFollow(ctx context.Context, c *model.Client, id string) (err error) {
|
func (s *as) UnFollow(ctx context.Context, c *model.Client, id string) (err error) {
|
||||||
|
|
|
@ -221,12 +221,12 @@ func (s *ls) Vote(ctx context.Context, c *model.Client, id string, choices []str
|
||||||
return s.Service.Vote(ctx, c, id, choices)
|
return s.Service.Vote(ctx, c, id, choices)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ls) Follow(ctx context.Context, c *model.Client, id string) (err error) {
|
func (s *ls) Follow(ctx context.Context, c *model.Client, id string, reblogs *bool) (err error) {
|
||||||
defer func(begin time.Time) {
|
defer func(begin time.Time) {
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
||||||
"Follow", id, time.Since(begin), err)
|
"Follow", id, time.Since(begin), err)
|
||||||
}(time.Now())
|
}(time.Now())
|
||||||
return s.Service.Follow(ctx, c, id)
|
return s.Service.Follow(ctx, c, id, reblogs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ls) UnFollow(ctx context.Context, c *model.Client, id string) (err error) {
|
func (s *ls) UnFollow(ctx context.Context, c *model.Client, id string) (err error) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ type Service interface {
|
||||||
Retweet(ctx context.Context, c *model.Client, id string) (count int64, err error)
|
Retweet(ctx context.Context, c *model.Client, id string) (count int64, err error)
|
||||||
UnRetweet(ctx context.Context, c *model.Client, id string) (count int64, err error)
|
UnRetweet(ctx context.Context, c *model.Client, id string) (count int64, err error)
|
||||||
Vote(ctx context.Context, c *model.Client, id string, choices []string) (err error)
|
Vote(ctx context.Context, c *model.Client, id string, choices []string) (err error)
|
||||||
Follow(ctx context.Context, c *model.Client, id string) (err error)
|
Follow(ctx context.Context, c *model.Client, id string, reblogs *bool) (err error)
|
||||||
UnFollow(ctx context.Context, c *model.Client, id string) (err error)
|
UnFollow(ctx context.Context, c *model.Client, id string) (err error)
|
||||||
Mute(ctx context.Context, c *model.Client, id string) (err error)
|
Mute(ctx context.Context, c *model.Client, id string) (err error)
|
||||||
UnMute(ctx context.Context, c *model.Client, id string) (err error)
|
UnMute(ctx context.Context, c *model.Client, id string) (err error)
|
||||||
|
@ -811,8 +811,8 @@ func (svc *service) Vote(ctx context.Context, c *model.Client, id string,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Follow(ctx context.Context, c *model.Client, id string) (err error) {
|
func (svc *service) Follow(ctx context.Context, c *model.Client, id string, reblogs *bool) (err error) {
|
||||||
_, err = c.AccountFollow(ctx, id)
|
_, err = c.AccountFollow(ctx, id, reblogs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,14 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
||||||
ctx := newCtxWithSesionCSRF(req, req.FormValue("csrf_token"))
|
ctx := newCtxWithSesionCSRF(req, req.FormValue("csrf_token"))
|
||||||
id, _ := mux.Vars(req)["id"]
|
id, _ := mux.Vars(req)["id"]
|
||||||
|
|
||||||
err := s.Follow(ctx, c, id)
|
var reblogs *bool
|
||||||
|
r, ok := req.URL.Query()["reblogs"]
|
||||||
|
if ok && len(r) > 0 {
|
||||||
|
reblogs = new(bool)
|
||||||
|
*reblogs = r[0] == "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
err := s.Follow(ctx, c, id, reblogs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
s.ServeErrorPage(ctx, c, err)
|
s.ServeErrorPage(ctx, c, err)
|
||||||
|
|
|
@ -75,6 +75,18 @@
|
||||||
<input type="submit" value="mute" class="btn-link">
|
<input type="submit" value="mute" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
-
|
||||||
|
{{if .User.Pleroma.Relationship.ShowingReblogs}}
|
||||||
|
<form class="d-inline" action="/follow/{{.User.ID}}?reblogs=false" method="post">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="submit" value="hide retweets" class="btn-link">
|
||||||
|
</form>
|
||||||
|
{{else}}
|
||||||
|
<form class="d-inline" action="/follow/{{.User.ID}}" method="post">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="submit" value="show retweets" class="btn-link">
|
||||||
|
</form>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in a new issue