mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-22 23:13:00 +00:00
Partially selectable reblogs visibility (fluoride required fix)
This commit is contained in:
parent
a678b620a1
commit
8c41878b6d
@ -200,9 +200,11 @@ func (c *Client) UnReaction(ctx context.Context, id string, emoji string) (*Stat
|
||||
}
|
||||
|
||||
// Reblog is reblog the toot of id and return status of reblog.
|
||||
func (c *Client) Reblog(ctx context.Context, id string) (*Status, error) {
|
||||
func (c *Client) Reblog(ctx context.Context, id string, visibility string) (*Status, error) {
|
||||
var status Status
|
||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/reblog", id), nil, &status, nil)
|
||||
params := url.Values{}
|
||||
params.Set("visibility", visibility)
|
||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/reblog", id), params, &status, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1052,8 +1052,8 @@ func (s *service) UnReact(c *client, id string, emoji string) (count int64, err
|
||||
return
|
||||
}
|
||||
|
||||
func (s *service) Retweet(c *client, id string) (count int64, err error) {
|
||||
st, err := c.Reblog(c.ctx, id)
|
||||
func (s *service) Retweet(c *client, id string, visibility string) (count int64, err error) {
|
||||
st, err := c.Reblog(c.ctx, id, visibility)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -381,7 +381,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
||||
retweet := handle(func(c *client) error {
|
||||
id, _ := mux.Vars(c.r)["id"]
|
||||
rid := c.r.FormValue("retweeted_by_id")
|
||||
_, err := s.Retweet(c, id)
|
||||
visibility := c.r.FormValue("retweet_visibility")
|
||||
_, err := s.Retweet(c, id, visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -773,7 +774,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
||||
|
||||
fRetweet := handle(func(c *client) error {
|
||||
id, _ := mux.Vars(c.r)["id"]
|
||||
count, err := s.Retweet(c, id)
|
||||
visibility := c.r.FormValue("retweet_visibility")
|
||||
count, err := s.Retweet(c, id, visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ var reverseActions = {
|
||||
|
||||
var csrfToken = "";
|
||||
var antiDopamineMode = false;
|
||||
var retweetVisibility = "public"
|
||||
|
||||
function checkCSRFToken() {
|
||||
var tag = document.querySelector("meta[name='csrf_token']");
|
||||
@ -22,6 +23,12 @@ function checkAntiDopamineMode() {
|
||||
antiDopamineMode = tag.getAttribute("content") === "true";
|
||||
}
|
||||
|
||||
function checkRetweetVisibility() {
|
||||
var tag = document.querySelector("meta[name='retweet_visibility']");
|
||||
if (tag)
|
||||
retweetVisibility = tag.getAttribute("content");
|
||||
}
|
||||
|
||||
function http(method, url, body, type, success, error) {
|
||||
var req = new XMLHttpRequest();
|
||||
req.onload = function() {
|
||||
@ -97,7 +104,7 @@ function handleRetweetForm(id, f) {
|
||||
updateActionForm(id, forms[i], reverseActions[action]);
|
||||
}
|
||||
|
||||
var body = "csrf_token=" + encodeURIComponent(csrfToken);
|
||||
var body = "csrf_token=" + encodeURIComponent(csrfToken) + "&retweet_visibility=" + encodeURIComponent(retweetVisibility);
|
||||
var contentType = "application/x-www-form-urlencoded";
|
||||
http("POST", "/fluoride/" + action + "/" + id,
|
||||
body, contentType, function(res, type) {
|
||||
@ -288,6 +295,7 @@ function onPaste(e) {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
checkCSRFToken();
|
||||
checkAntiDopamineMode();
|
||||
checkRetweetVisibility();
|
||||
|
||||
var statuses = document.querySelectorAll(".status-container");
|
||||
for (var i = 0; i < statuses.length; i++) {
|
||||
|
@ -225,11 +225,27 @@
|
||||
<div class="status-action">
|
||||
{{$rt := "retweet"}} {{if .Reblogged}} {{$rt = "unretweet"}} {{end}}
|
||||
<form class="status-retweet" data-action="{{$rt}}" action="/{{$rt}}/{{.ID}}" method="post" target="_self">
|
||||
|
||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
||||
<input type="submit" value="{{$rt}}" class="btn-link"
|
||||
<div class="more-container">
|
||||
|
||||
<input type="submit" value="{{$rt}}" class="btn-link"
|
||||
{{if or (eq .Visibility "private") (eq .Visibility "direct")}}title="this status cannot be retweeted" disabled{{end}}>
|
||||
<div class="more-content">
|
||||
{{if or (eq .Visibility "private") (eq .Visibility "direct")}}
|
||||
Locked
|
||||
{{else}}
|
||||
<input type="radio" id="retweet_visibility" name="retweet_visibility" value="public" checked>
|
||||
<label for="retweet_visibility">public</label>
|
||||
<input type="radio" id="retweet_visibility" name="retweet_visibility" value="unlisted">
|
||||
<label for="retweet_visibility">unlisted</label>
|
||||
<input type="radio" id="retweet_visibility" name="retweet_visibility" value="private">
|
||||
<label for="retweet_visibility">private</label>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<a class="status-retweet-count" href="/retweetedby/{{.ID}}" title="click to see the the list">
|
||||
{{if and (not $.Ctx.AntiDopamineMode) .ReblogsCount}}
|
||||
({{DisplayInteractionCount .ReblogsCount}})
|
||||
|
Loading…
Reference in New Issue
Block a user