鏡像自
https://gitea.phreedom.club/localhost_frssoft/bloat.git
已同步 2025-07-06 17:54:18 +00:00
Add follow request support
這個提交存在於:
父節點
384179e518
當前提交
91f68ccfb3
共有 5 個檔案被更改,包括 114 行新增 和 4 行删除
|
@ -486,6 +486,18 @@ func (s *service) UserPage(c *client, id string, pageType string,
|
|||
nextLink = fmt.Sprintf("/user/%s/likes?max_id=%s",
|
||||
id, pg.MaxID)
|
||||
}
|
||||
case "requests":
|
||||
if !isCurrent {
|
||||
return errInvalidArgument
|
||||
}
|
||||
users, err = c.GetFollowRequests(ctx, &pg)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(users) == 20 && len(pg.MaxID) > 0 {
|
||||
nextLink = fmt.Sprintf("/user/%s/requests?max_id=%s",
|
||||
id, pg.MaxID)
|
||||
}
|
||||
default:
|
||||
return errInvalidArgument
|
||||
}
|
||||
|
@ -817,6 +829,14 @@ func (s *service) UnFollow(c *client, id string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (s *service) Accept(c *client, id string) (err error) {
|
||||
return c.FollowRequestAuthorize(ctx, id)
|
||||
}
|
||||
|
||||
func (s *service) Reject(c *client, id string) (err error) {
|
||||
return c.FollowRequestReject(ctx, id)
|
||||
}
|
||||
|
||||
func (s *service) Mute(c *client, id string) (err error) {
|
||||
_, err = c.AccountMute(ctx, id)
|
||||
return
|
||||
|
|
|
@ -403,6 +403,26 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
|||
return nil
|
||||
}, CSRF, HTML)
|
||||
|
||||
accept := handle(func(c *client) error {
|
||||
id, _ := mux.Vars(c.Req)["id"]
|
||||
err := s.Accept(c, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
redirect(c, c.Req.Header.Get("Referer"))
|
||||
return nil
|
||||
}, CSRF, HTML)
|
||||
|
||||
reject := handle(func(c *client) error {
|
||||
id, _ := mux.Vars(c.Req)["id"]
|
||||
err := s.Reject(c, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
redirect(c, c.Req.Header.Get("Referer"))
|
||||
return nil
|
||||
}, CSRF, HTML)
|
||||
|
||||
mute := handle(func(c *client) error {
|
||||
id, _ := mux.Vars(c.Req)["id"]
|
||||
err := s.Mute(c, id)
|
||||
|
@ -634,6 +654,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
|||
r.HandleFunc("/vote/{id}", vote).Methods(http.MethodPost)
|
||||
r.HandleFunc("/follow/{id}", follow).Methods(http.MethodPost)
|
||||
r.HandleFunc("/unfollow/{id}", unfollow).Methods(http.MethodPost)
|
||||
r.HandleFunc("/accept/{id}", accept).Methods(http.MethodPost)
|
||||
r.HandleFunc("/reject/{id}", reject).Methods(http.MethodPost)
|
||||
r.HandleFunc("/mute/{id}", mute).Methods(http.MethodPost)
|
||||
r.HandleFunc("/unmute/{id}", unMute).Methods(http.MethodPost)
|
||||
r.HandleFunc("/block/{id}", block).Methods(http.MethodPost)
|
||||
|
|
載入中…
新增表格
新增連結
新增問題並參考