mirror of
https://git.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-22 12:01:27 +00:00
Fix duplicate status ids
Use retweeted_by_id to focus target tweet
This commit is contained in:
parent
50e58c4e01
commit
ca711e62ec
|
@ -56,6 +56,7 @@ type Status struct {
|
||||||
ReplyNumber int `json:"reply_number"`
|
ReplyNumber int `json:"reply_number"`
|
||||||
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
||||||
MaskNSFW bool `json:"mask_nsfw"`
|
MaskNSFW bool `json:"mask_nsfw"`
|
||||||
|
RetweetedByID string `json:"retweeted_by_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Context hold information for mastodon context.
|
// Context hold information for mastodon context.
|
||||||
|
|
|
@ -282,6 +282,7 @@ func (svc *service) ServeTimelinePage(ctx context.Context, client io.Writer,
|
||||||
statuses[i].ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
statuses[i].ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
||||||
statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
if statuses[i].Reblog != nil {
|
if statuses[i].Reblog != nil {
|
||||||
|
statuses[i].Reblog.RetweetedByID = statuses[i].ID
|
||||||
statuses[i].Reblog.ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
statuses[i].Reblog.ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
||||||
statuses[i].Reblog.MaskNSFW = c.Session.Settings.MaskNSFW
|
statuses[i].Reblog.MaskNSFW = c.Session.Settings.MaskNSFW
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,52 +159,76 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
||||||
r.HandleFunc("/like/{id}", func(w http.ResponseWriter, req *http.Request) {
|
r.HandleFunc("/like/{id}", func(w http.ResponseWriter, req *http.Request) {
|
||||||
ctx := getContextWithSession(context.Background(), req)
|
ctx := getContextWithSession(context.Background(), req)
|
||||||
id, _ := mux.Vars(req)["id"]
|
id, _ := mux.Vars(req)["id"]
|
||||||
err := s.Like(ctx, w, nil, id)
|
retweetedByID := req.FormValue("retweeted_by_id")
|
||||||
|
|
||||||
|
_, err := s.Like(ctx, w, nil, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.ServeErrorPage(ctx, w, err)
|
s.ServeErrorPage(ctx, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+id)
|
rID := id
|
||||||
|
if len(retweetedByID) > 0 {
|
||||||
|
rID = retweetedByID
|
||||||
|
}
|
||||||
|
w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+rID)
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
}).Methods(http.MethodPost)
|
}).Methods(http.MethodPost)
|
||||||
|
|
||||||
r.HandleFunc("/unlike/{id}", func(w http.ResponseWriter, req *http.Request) {
|
r.HandleFunc("/unlike/{id}", func(w http.ResponseWriter, req *http.Request) {
|
||||||
ctx := getContextWithSession(context.Background(), req)
|
ctx := getContextWithSession(context.Background(), req)
|
||||||
id, _ := mux.Vars(req)["id"]
|
id, _ := mux.Vars(req)["id"]
|
||||||
err := s.UnLike(ctx, w, nil, id)
|
retweetedByID := req.FormValue("retweeted_by_id")
|
||||||
|
|
||||||
|
_, err := s.UnLike(ctx, w, nil, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.ServeErrorPage(ctx, w, err)
|
s.ServeErrorPage(ctx, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+id)
|
rID := id
|
||||||
|
if len(retweetedByID) > 0 {
|
||||||
|
rID = retweetedByID
|
||||||
|
}
|
||||||
|
w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+rID)
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
}).Methods(http.MethodPost)
|
}).Methods(http.MethodPost)
|
||||||
|
|
||||||
r.HandleFunc("/retweet/{id}", func(w http.ResponseWriter, req *http.Request) {
|
r.HandleFunc("/retweet/{id}", func(w http.ResponseWriter, req *http.Request) {
|
||||||
ctx := getContextWithSession(context.Background(), req)
|
ctx := getContextWithSession(context.Background(), req)
|
||||||
id, _ := mux.Vars(req)["id"]
|
id, _ := mux.Vars(req)["id"]
|
||||||
err := s.Retweet(ctx, w, nil, id)
|
retweetedByID := req.FormValue("retweeted_by_id")
|
||||||
|
|
||||||
|
_, err := s.Retweet(ctx, w, nil, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.ServeErrorPage(ctx, w, err)
|
s.ServeErrorPage(ctx, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+id)
|
rID := id
|
||||||
|
if len(retweetedByID) > 0 {
|
||||||
|
rID = retweetedByID
|
||||||
|
}
|
||||||
|
w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+rID)
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
}).Methods(http.MethodPost)
|
}).Methods(http.MethodPost)
|
||||||
|
|
||||||
r.HandleFunc("/unretweet/{id}", func(w http.ResponseWriter, req *http.Request) {
|
r.HandleFunc("/unretweet/{id}", func(w http.ResponseWriter, req *http.Request) {
|
||||||
ctx := getContextWithSession(context.Background(), req)
|
ctx := getContextWithSession(context.Background(), req)
|
||||||
id, _ := mux.Vars(req)["id"]
|
id, _ := mux.Vars(req)["id"]
|
||||||
err := s.UnRetweet(ctx, w, nil, id)
|
retweetedByID := req.FormValue("retweeted_by_id")
|
||||||
|
|
||||||
|
_, err := s.UnRetweet(ctx, w, nil, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.ServeErrorPage(ctx, w, err)
|
s.ServeErrorPage(ctx, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+id)
|
rID := id
|
||||||
|
if len(retweetedByID) > 0 {
|
||||||
|
rID = retweetedByID
|
||||||
|
}
|
||||||
|
w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+rID)
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
}).Methods(http.MethodPost)
|
}).Methods(http.MethodPost)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div id="status-{{if .Reblog}}{{.Reblog.ID}}{{else}}{{.ID}}{{end}}" class="status-container-container">
|
<div id="status-{{.ID}}" class="status-container-container">
|
||||||
{{if .Reblog}}
|
{{if .Reblog}}
|
||||||
<div class="retweet-info">
|
<div class="retweet-info">
|
||||||
<a class="img-link" href="/user/{{.Account.ID}}">
|
<a class="img-link" href="/user/{{.Account.ID}}">
|
||||||
|
@ -102,11 +102,13 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if .Reblogged}}
|
{{if .Reblogged}}
|
||||||
<form class="status-retweet" action="/unretweet/{{.ID}}" method="post">
|
<form class="status-retweet" action="/unretweet/{{.ID}}" method="post">
|
||||||
<input type="image" src="/static/icons/retweeted.png" alt="undo retweet" class="icon" title="undo retweet">
|
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
|
||||||
|
<input type="image" src="/static/icons/retweeted.png" alt="undo retweet" class="icon" title="undo retweet">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form class="status-retweet" action="/retweet/{{.ID}}" method="post">
|
<form class="status-retweet" action="/retweet/{{.ID}}" method="post">
|
||||||
<input type="image" src="/static/icons/retweet.png" alt="retweet" class="icon" title="retweet">
|
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
|
||||||
|
<input type="image" src="/static/icons/retweet.png" alt="retweet" class="icon" title="retweet">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -117,11 +119,13 @@
|
||||||
<div class="status-action">
|
<div class="status-action">
|
||||||
{{if .Favourited}}
|
{{if .Favourited}}
|
||||||
<form class="status-like" action="/unlike/{{.ID}}" method="post">
|
<form class="status-like" action="/unlike/{{.ID}}" method="post">
|
||||||
<input type="image" src="/static/icons/liked.png" alt="unlike" class="icon" title="unlike">
|
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
|
||||||
|
<input type="image" src="/static/icons/liked.png" alt="unlike" class="icon" title="unlike">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form class="status-like" action="/like/{{.ID}}" method="post">
|
<form class="status-like" action="/like/{{.ID}}" method="post">
|
||||||
<input type="image" src="/static/icons/star-o.png" alt="like" class="icon" title="like">
|
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
|
||||||
|
<input type="image" src="/static/icons/star-o.png" alt="like" class="icon" title="like">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
<a class="status-action-count" href="/likedby/{{.ID}}" title="click to see the the list">
|
<a class="status-action-count" href="/likedby/{{.ID}}" title="click to see the the list">
|
||||||
|
|
Loading…
Reference in a new issue