aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-04-19 05:57:40 +0000
committerr <r@freesoftwareextremist.com>2020-04-19 05:57:40 +0000
commit91d87b01752a35f67508d5eb6f804946d7f9f7f2 (patch)
tree65cfc14c69d4ae3b554b600457c39293bf1a79c3 /service
parent04af1b93dc95d761b4e05a448c9d86ac67623ff6 (diff)
downloadbloat-91d87b01752a35f67508d5eb6f804946d7f9f7f2.tar.gz
bloat-91d87b01752a35f67508d5eb6f804946d7f9f7f2.zip
Add account {hide,show}retweets
Diffstat (limited to 'service')
-rw-r--r--service/auth.go4
-rw-r--r--service/logging.go4
-rw-r--r--service/service.go6
-rw-r--r--service/transport.go9
4 files changed, 15 insertions, 8 deletions
diff --git a/service/auth.go b/service/auth.go
index dd114b4..a7c4c15 100644
--- a/service/auth.go
+++ b/service/auth.go
@@ -292,7 +292,7 @@ func (s *as) Vote(ctx context.Context, c *model.Client, id string,
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)
if err != nil {
return
@@ -301,7 +301,7 @@ func (s *as) Follow(ctx context.Context, c *model.Client, id string) (err error)
if err != nil {
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) {
diff --git a/service/logging.go b/service/logging.go
index c16cdb3..16279cc 100644
--- a/service/logging.go
+++ b/service/logging.go
@@ -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)
}
-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) {
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
"Follow", id, time.Since(begin), err)
}(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) {
diff --git a/service/service.go b/service/service.go
index 3a48e77..be83bd0 100644
--- a/service/service.go
+++ b/service/service.go
@@ -46,7 +46,7 @@ type Service interface {
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)
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)
Mute(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
}
-func (svc *service) Follow(ctx context.Context, c *model.Client, id string) (err error) {
- _, err = c.AccountFollow(ctx, id)
+func (svc *service) Follow(ctx context.Context, c *model.Client, id string, reblogs *bool) (err error) {
+ _, err = c.AccountFollow(ctx, id, reblogs)
return
}
diff --git a/service/transport.go b/service/transport.go
index 108cc18..69b28ec 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -458,7 +458,14 @@ func NewHandler(s Service, staticDir string) http.Handler {
ctx := newCtxWithSesionCSRF(req, req.FormValue("csrf_token"))
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 {
w.WriteHeader(http.StatusInternalServerError)
s.ServeErrorPage(ctx, c, err)