mirror of
https://git.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-25 13:21:28 +00:00
Add follow request support
This commit is contained in:
parent
384179e518
commit
91f68ccfb3
|
@ -486,6 +486,18 @@ func (s *service) UserPage(c *client, id string, pageType string,
|
||||||
nextLink = fmt.Sprintf("/user/%s/likes?max_id=%s",
|
nextLink = fmt.Sprintf("/user/%s/likes?max_id=%s",
|
||||||
id, pg.MaxID)
|
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:
|
default:
|
||||||
return errInvalidArgument
|
return errInvalidArgument
|
||||||
}
|
}
|
||||||
|
@ -817,6 +829,14 @@ func (s *service) UnFollow(c *client, id string) (err error) {
|
||||||
return
|
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) {
|
func (s *service) Mute(c *client, id string) (err error) {
|
||||||
_, err = c.AccountMute(ctx, id)
|
_, err = c.AccountMute(ctx, id)
|
||||||
return
|
return
|
||||||
|
|
|
@ -403,6 +403,26 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
||||||
return nil
|
return nil
|
||||||
}, CSRF, HTML)
|
}, 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 {
|
mute := handle(func(c *client) error {
|
||||||
id, _ := mux.Vars(c.Req)["id"]
|
id, _ := mux.Vars(c.Req)["id"]
|
||||||
err := s.Mute(c, 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("/vote/{id}", vote).Methods(http.MethodPost)
|
||||||
r.HandleFunc("/follow/{id}", follow).Methods(http.MethodPost)
|
r.HandleFunc("/follow/{id}", follow).Methods(http.MethodPost)
|
||||||
r.HandleFunc("/unfollow/{id}", unfollow).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("/mute/{id}", mute).Methods(http.MethodPost)
|
||||||
r.HandleFunc("/unmute/{id}", unMute).Methods(http.MethodPost)
|
r.HandleFunc("/unmute/{id}", unMute).Methods(http.MethodPost)
|
||||||
r.HandleFunc("/block/{id}", block).Methods(http.MethodPost)
|
r.HandleFunc("/block/{id}", block).Methods(http.MethodPost)
|
||||||
|
|
|
@ -38,6 +38,35 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{else if eq .Type "follow_request"}}
|
||||||
|
<div class="notification-follow-container">
|
||||||
|
<div class="status-profile-img-container">
|
||||||
|
<a class="img-link" href="/user/{{.Account.ID}}">
|
||||||
|
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" title="@{{.Account.Acct}}" alt="profile-avatar" height="48" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="notification-follow">
|
||||||
|
<div class="notification-info-text">
|
||||||
|
<bdi class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </bdi>
|
||||||
|
<span class="notification-text"> wants to follow you -
|
||||||
|
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}">{{TimeSince .CreatedAt}}</time>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="/user/{{.Account.ID}}"> <span class="status-uname"> @{{.Account.Acct}} </span> </a>
|
||||||
|
</div>
|
||||||
|
<form class="d-inline" action="/accept/{{.Account.ID}}" method="post" target="_self">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="submit" value="accept" class="btn-link">
|
||||||
|
</form>
|
||||||
|
-
|
||||||
|
<form class="d-inline" action="/reject/{{.Account.ID}}" method="post" target="_self">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="submit" value="reject" class="btn-link">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{else if eq .Type "mention"}}
|
{{else if eq .Type "mention"}}
|
||||||
{{template "status" (WithContext .Status $.Ctx)}}
|
{{template "status" (WithContext .Status $.Ctx)}}
|
||||||
|
|
||||||
|
|
34
templates/requestlist.tmpl
Normal file
34
templates/requestlist.tmpl
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{{with .Data}}
|
||||||
|
<div>
|
||||||
|
{{range .}}
|
||||||
|
<div class="user-list-item">
|
||||||
|
<div class="user-list-profile-img">
|
||||||
|
<a class="img-link" href="/user/{{.ID}}">
|
||||||
|
<img class="status-profile-img" src="{{.AvatarStatic}}" title="@{{.Acct}}" alt="avatar" height="48" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="user-list-name">
|
||||||
|
<div>
|
||||||
|
<div class="status-dname"> {{EmojiFilter .DisplayName .Emojis}} </div>
|
||||||
|
<a class="img-link" href="/user/{{.ID}}">
|
||||||
|
<div class="status-uname"> @{{.Acct}} </div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<form class="d-inline" action="/accept/{{.ID}}" method="post" target="_self">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="submit" value="accept" class="btn-link">
|
||||||
|
</form>
|
||||||
|
-
|
||||||
|
<form class="d-inline" action="/reject/{{.ID}}" method="post" target="_self">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="submit" value="reject" class="btn-link">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="no-data-found">No data found</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="no-data-found">No data found</div>
|
||||||
|
{{end}}
|
|
@ -99,10 +99,11 @@
|
||||||
</div>
|
</div>
|
||||||
{{if .IsCurrent}}
|
{{if .IsCurrent}}
|
||||||
<div>
|
<div>
|
||||||
<a href="/user/{{.User.ID}}/bookmarks"> bookmarks </a> -
|
<a href="/user/{{.User.ID}}/bookmarks"> bookmarks </a>
|
||||||
<a href="/user/{{.User.ID}}/likes"> likes </a> -
|
- <a href="/user/{{.User.ID}}/likes"> likes </a>
|
||||||
<a href="/user/{{.User.ID}}/mutes"> mutes </a> -
|
- <a href="/user/{{.User.ID}}/mutes"> mutes </a>
|
||||||
<a href="/user/{{.User.ID}}/blocks"> blocks </a>
|
- <a href="/user/{{.User.ID}}/blocks"> blocks </a>
|
||||||
|
{{if .User.Locked}}- <a href="/user/{{.User.ID}}/requests"> requests </a>{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div>
|
<div>
|
||||||
|
@ -162,6 +163,10 @@
|
||||||
{{else if eq .Type "blocks"}}
|
{{else if eq .Type "blocks"}}
|
||||||
<div class="page-title"> Blocks </div>
|
<div class="page-title"> Blocks </div>
|
||||||
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||||
|
|
||||||
|
{{else if eq .Type "requests"}}
|
||||||
|
<div class="page-title"> Follow requests </div>
|
||||||
|
{{template "requestlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
|
|
Loading…
Reference in a new issue