/
delete.go
40 lines (33 loc) · 1.01 KB
/
delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package follow
import (
"github.com/allocamelus/allocamelus/internal/router/handlers/api/apierr"
"github.com/allocamelus/allocamelus/internal/router/handlers/api/shared"
"github.com/allocamelus/allocamelus/internal/user"
"github.com/allocamelus/allocamelus/internal/user/session"
"github.com/allocamelus/allocamelus/pkg/fiberutil"
"github.com/gofiber/fiber/v2"
)
// Delete remove follow
func Delete(c *fiber.Ctx) error {
_, userID, hasErr, err := shared.GetUserNameIDResp(c)
if hasErr {
return err
}
err = user.Unfollow(session.Context(c).UserID, userID)
if err != nil {
return apierr.ErrSomethingWentWrong(c)
}
return fiberutil.JSON(c, 200, shared.SuccessErrResp{Success: true})
}
// Decline follow
func Decline(c *fiber.Ctx) error {
_, userID, hasErr, err := shared.GetUserNameIDResp(c)
if hasErr {
return err
}
err = user.Decline(session.Context(c).UserID, userID)
if err != nil {
return apierr.ErrSomethingWentWrong(c)
}
return fiberutil.JSON(c, 200, shared.SuccessErrResp{Success: true})
}