From a8dbbec988cf1ed42a051d1a0dfa9987d890d440 Mon Sep 17 00:00:00 2001 From: r Date: Wed, 8 Jan 2020 18:16:06 +0000 Subject: Add fluoride mode --- service/service.go | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'service/service.go') diff --git a/service/service.go b/service/service.go index 47e3de9..301e33d 100644 --- a/service/service.go +++ b/service/service.go @@ -44,10 +44,10 @@ type Service interface { ServeSearchPage(ctx context.Context, client io.Writer, c *model.Client, q string, qType string, offset int) (err error) ServeSettingsPage(ctx context.Context, client io.Writer, c *model.Client) (err error) SaveSettings(ctx context.Context, client io.Writer, c *model.Client, settings *model.Settings) (err error) - Like(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) - UnLike(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) - Retweet(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) - UnRetweet(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) + Like(ctx context.Context, client io.Writer, c *model.Client, id string) (count int64, err error) + UnLike(ctx context.Context, client io.Writer, c *model.Client, id string) (count int64, err error) + Retweet(ctx context.Context, client io.Writer, c *model.Client, id string) (count int64, err error) + UnRetweet(ctx context.Context, client io.Writer, c *model.Client, id string) (count int64, err error) PostTweet(ctx context.Context, client io.Writer, c *model.Client, content string, replyToID string, format string, visibility string, isNSFW bool, files []*multipart.FileHeader) (id string, err error) Follow(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) UnFollow(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) @@ -795,6 +795,7 @@ func (svc *service) getCommonData(ctx context.Context, client io.Writer, c *mode Title: "Web", NotificationCount: 0, CustomCSS: svc.customCSS, + FluorideMode: c.Session.Settings.FluorideMode, } if c != nil && c.Session.IsLoggedIn() { @@ -826,23 +827,41 @@ func (svc *service) getCommonData(ctx context.Context, client io.Writer, c *mode return } -func (svc *service) Like(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) { - _, err = c.Favourite(ctx, id) +func (svc *service) Like(ctx context.Context, client io.Writer, c *model.Client, id string) (count int64, err error) { + s, err := c.Favourite(ctx, id) + if err != nil { + return + } + count = s.FavouritesCount return } -func (svc *service) UnLike(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) { - _, err = c.Unfavourite(ctx, id) +func (svc *service) UnLike(ctx context.Context, client io.Writer, c *model.Client, id string) (count int64, err error) { + s, err := c.Unfavourite(ctx, id) + if err != nil { + return + } + count = s.FavouritesCount return } -func (svc *service) Retweet(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) { - _, err = c.Reblog(ctx, id) +func (svc *service) Retweet(ctx context.Context, client io.Writer, c *model.Client, id string) (count int64, err error) { + s, err := c.Reblog(ctx, id) + if err != nil { + return + } + if s.Reblog != nil { + count = s.Reblog.ReblogsCount + } return } -func (svc *service) UnRetweet(ctx context.Context, client io.Writer, c *model.Client, id string) (err error) { - _, err = c.Unreblog(ctx, id) +func (svc *service) UnRetweet(ctx context.Context, client io.Writer, c *model.Client, id string) (count int64, err error) { + s, err := c.Unreblog(ctx, id) + if err != nil { + return + } + count = s.ReblogsCount return } -- cgit v1.2.3