mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-13 08:19:20 +02:00
Added pin\unpin statuses; Status ID in code tag
This commit is contained in:
parent
9a6e1324d5
commit
4df1f096be
|
@ -332,15 +332,25 @@ func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) {
|
|||
if toot.ContentType != "" {
|
||||
params.Set("content_type", toot.ContentType)
|
||||
}
|
||||
|
||||
var status Status
|
||||
err := c.doAPI(ctx, http.MethodPost, "/api/v1/statuses", params, &status, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
// Pin pin your status.
|
||||
func (c *Client) Pin(ctx context.Context, id string) error {
|
||||
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/pin", id), nil, nil, nil)
|
||||
}
|
||||
|
||||
// UnPin unpin your status.
|
||||
func (c *Client) UnPin(ctx context.Context, id string) error {
|
||||
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unpin", id), nil, nil, nil)
|
||||
}
|
||||
|
||||
// DeleteStatus delete the toot.
|
||||
func (c *Client) DeleteStatus(ctx context.Context, id string) error {
|
||||
return c.doAPI(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/statuses/%s", id), nil, nil, nil)
|
||||
|
|
|
@ -1150,6 +1150,14 @@ func (s *service) UnMuteConversation(c *client, id string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (s *service) Pin(c *client, id string) (err error) {
|
||||
return c.Pin(c.ctx, id)
|
||||
}
|
||||
|
||||
func (s *service) UnPin(c *client, id string) (err error) {
|
||||
return c.UnPin(c.ctx, id)
|
||||
}
|
||||
|
||||
func (s *service) Delete(c *client, id string) (err error) {
|
||||
return c.DeleteStatus(c.ctx, id)
|
||||
}
|
||||
|
|
|
@ -572,6 +572,26 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
|||
return nil
|
||||
}, CSRF, HTML)
|
||||
|
||||
pin := handle(func(c *client) error {
|
||||
id, _ := mux.Vars(c.r)["id"]
|
||||
err := s.Pin(c, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
redirect(c, c.r.FormValue("referrer"))
|
||||
return nil
|
||||
}, CSRF, HTML)
|
||||
|
||||
unpin := handle(func(c *client) error {
|
||||
id, _ := mux.Vars(c.r)["id"]
|
||||
err := s.UnPin(c, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
redirect(c, c.r.FormValue("referrer"))
|
||||
return nil
|
||||
}, CSRF, HTML)
|
||||
|
||||
delete := handle(func(c *client) error {
|
||||
id, _ := mux.Vars(c.r)["id"]
|
||||
err := s.Delete(c, id)
|
||||
|
@ -794,6 +814,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
|||
r.HandleFunc("/settings", settings).Methods(http.MethodPost)
|
||||
r.HandleFunc("/muteconv/{id}", muteConversation).Methods(http.MethodPost)
|
||||
r.HandleFunc("/unmuteconv/{id}", unMuteConversation).Methods(http.MethodPost)
|
||||
r.HandleFunc("/pin/{id}", pin).Methods(http.MethodPost)
|
||||
r.HandleFunc("/unpin/{id}", unpin).Methods(http.MethodPost)
|
||||
r.HandleFunc("/delete/{id}", delete).Methods(http.MethodPost)
|
||||
r.HandleFunc("/notifications/read", readNotifications).Methods(http.MethodPost)
|
||||
r.HandleFunc("/bookmark/{id}", bookmark).Methods(http.MethodPost)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</a>
|
||||
<div class="more-container">
|
||||
<div class="remote-link">
|
||||
{{if .IDNumbers}}#{{index .IDNumbers .ID}}{{end}} {{.Visibility}} {{.ID}}
|
||||
{{if .IDNumbers}}#{{index .IDNumbers .ID}}{{end}} {{.Visibility}} <code title="Status ID">{{.ID}}</code>
|
||||
</div>
|
||||
<div class="more-content">
|
||||
<a class="more-link" href="{{.URL}}" target="_blank">
|
||||
|
@ -67,6 +67,12 @@
|
|||
</form>
|
||||
{{end}}
|
||||
{{if eq $.Ctx.UserID .Account.ID}}
|
||||
{{$pin := "pin"}} {{if .Pinned}} {{$pin = "unpin"}} {{end}}
|
||||
<form action="/{{$pin}}/{{.ID}}" method="post" target="_self">
|
||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||
<input type="submit" value="{{$pin}}" class="btn-link more-link">
|
||||
</form>
|
||||
<form action="/delete/{{.ID}}" method="post" target="_self">
|
||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||
|
|
Loading…
Reference in New Issue