mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-26 17:03:01 +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.
|
// 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
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1052,8 +1052,8 @@ func (s *service) UnReact(c *client, id string, emoji string) (count int64, err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) Retweet(c *client, id string) (count int64, err error) {
|
func (s *service) Retweet(c *client, id string, visibility string) (count int64, err error) {
|
||||||
st, err := c.Reblog(c.ctx, id)
|
st, err := c.Reblog(c.ctx, id, visibility)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
|||||||
retweet := handle(func(c *client) error {
|
retweet := handle(func(c *client) error {
|
||||||
id, _ := mux.Vars(c.r)["id"]
|
id, _ := mux.Vars(c.r)["id"]
|
||||||
rid := c.r.FormValue("retweeted_by_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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -773,7 +774,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
|||||||
|
|
||||||
fRetweet := handle(func(c *client) error {
|
fRetweet := handle(func(c *client) error {
|
||||||
id, _ := mux.Vars(c.r)["id"]
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ var reverseActions = {
|
|||||||
|
|
||||||
var csrfToken = "";
|
var csrfToken = "";
|
||||||
var antiDopamineMode = false;
|
var antiDopamineMode = false;
|
||||||
|
var retweetVisibility = "public"
|
||||||
|
|
||||||
function checkCSRFToken() {
|
function checkCSRFToken() {
|
||||||
var tag = document.querySelector("meta[name='csrf_token']");
|
var tag = document.querySelector("meta[name='csrf_token']");
|
||||||
@ -22,6 +23,12 @@ function checkAntiDopamineMode() {
|
|||||||
antiDopamineMode = tag.getAttribute("content") === "true";
|
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) {
|
function http(method, url, body, type, success, error) {
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
req.onload = function() {
|
req.onload = function() {
|
||||||
@ -97,7 +104,7 @@ function handleRetweetForm(id, f) {
|
|||||||
updateActionForm(id, forms[i], reverseActions[action]);
|
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";
|
var contentType = "application/x-www-form-urlencoded";
|
||||||
http("POST", "/fluoride/" + action + "/" + id,
|
http("POST", "/fluoride/" + action + "/" + id,
|
||||||
body, contentType, function(res, type) {
|
body, contentType, function(res, type) {
|
||||||
@ -288,6 +295,7 @@ function onPaste(e) {
|
|||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
checkCSRFToken();
|
checkCSRFToken();
|
||||||
checkAntiDopamineMode();
|
checkAntiDopamineMode();
|
||||||
|
checkRetweetVisibility();
|
||||||
|
|
||||||
var statuses = document.querySelectorAll(".status-container");
|
var statuses = document.querySelectorAll(".status-container");
|
||||||
for (var i = 0; i < statuses.length; i++) {
|
for (var i = 0; i < statuses.length; i++) {
|
||||||
|
@ -225,11 +225,27 @@
|
|||||||
<div class="status-action">
|
<div class="status-action">
|
||||||
{{$rt := "retweet"}} {{if .Reblogged}} {{$rt = "unretweet"}} {{end}}
|
{{$rt := "retweet"}} {{if .Reblogged}} {{$rt = "unretweet"}} {{end}}
|
||||||
<form class="status-retweet" data-action="{{$rt}}" action="/{{$rt}}/{{.ID}}" method="post" target="_self">
|
<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="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
<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}}>
|
{{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">
|
<a class="status-retweet-count" href="/retweetedby/{{.ID}}" title="click to see the the list">
|
||||||
{{if and (not $.Ctx.AntiDopamineMode) .ReblogsCount}}
|
{{if and (not $.Ctx.AntiDopamineMode) .ReblogsCount}}
|
||||||
({{DisplayInteractionCount .ReblogsCount}})
|
({{DisplayInteractionCount .ReblogsCount}})
|
||||||
|
Loading…
Reference in New Issue
Block a user