aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/auth.go8
-rw-r--r--service/logging.go8
-rw-r--r--service/service.go10
-rw-r--r--service/transport.go13
4 files changed, 39 insertions, 0 deletions
diff --git a/service/auth.go b/service/auth.go
index 7845675..c670130 100644
--- a/service/auth.go
+++ b/service/auth.go
@@ -107,6 +107,14 @@ func (s *as) ServeThreadPage(c *model.Client, id string, reply bool) (err error)
return s.Service.ServeThreadPage(c, id, reply)
}
+func (s *as) ServeStatusPopup(c *model.Client, id string) (err error) {
+ err = s.authenticateClient(c)
+ if err != nil {
+ return
+ }
+ return s.Service.ServeStatusPopup(c, id)
+}
+
func (s *as) ServeLikedByPage(c *model.Client, id string) (err error) {
err = s.authenticateClient(c)
if err != nil {
diff --git a/service/logging.go b/service/logging.go
index 3cb99bf..d283a55 100644
--- a/service/logging.go
+++ b/service/logging.go
@@ -67,6 +67,14 @@ func (s *ls) ServeThreadPage(c *model.Client, id string,
return s.Service.ServeThreadPage(c, id, reply)
}
+func (s *ls) ServeStatusPopup(c *model.Client, id string) (err error) {
+ defer func(begin time.Time) {
+ s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
+ "ServeStatusPopup", id, time.Since(begin), err)
+ }(time.Now())
+ return s.Service.ServeStatusPopup(c, id)
+}
+
func (s *ls) ServeLikedByPage(c *model.Client, id string) (err error) {
defer func(begin time.Time) {
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
diff --git a/service/service.go b/service/service.go
index 48aafda..82ff972 100644
--- a/service/service.go
+++ b/service/service.go
@@ -28,6 +28,7 @@ type Service interface {
ServeTimelinePage(c *model.Client, tType string, maxID string,
minID string) (err error)
ServeThreadPage(c *model.Client, id string, reply bool) (err error)
+ ServeStatusPopup(c *model.Client, id string) (err error)
ServeLikedByPage(c *model.Client, id string) (err error)
ServeRetweetedByPage(c *model.Client, id string) (err error)
ServeNotificationPage(c *model.Client, maxID string, minID string) (err error)
@@ -365,6 +366,15 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
return svc.renderer.Render(rCtx, c.Writer, renderer.ThreadPage, data)
}
+func (svc *service) ServeStatusPopup(c *model.Client, id string) (err error) {
+ status, err := c.GetStatus(ctx, id)
+ if err != nil {
+ return
+ }
+ rCtx := getRendererContext(c)
+ return svc.renderer.Render(rCtx, c.Writer, renderer.StatusPopup, status)
+}
+
func (svc *service) ServeLikedByPage(c *model.Client, id string) (err error) {
likers, err := c.GetFavouritedBy(ctx, id, nil)
if err != nil {
diff --git a/service/transport.go b/service/transport.go
index 6c0975d..bacb19d 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -62,6 +62,7 @@ func serveJson(w io.Writer, data interface{}) (err error) {
func serveJsonError(w http.ResponseWriter, err error) {
var d = make(map[string]interface{})
d["error"] = err.Error()
+ w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusInternalServerError)
json.NewEncoder(w).Encode(d)
return
@@ -796,6 +797,17 @@ func NewHandler(s Service, staticDir string) http.Handler {
}
}
+ statusPopup := func(w http.ResponseWriter, req *http.Request) {
+ c := newClient(w, req, "")
+ id, _ := mux.Vars(req)["id"]
+
+ err := s.ServeStatusPopup(c, id)
+ if err != nil {
+ serveJsonError(w, err)
+ return
+ }
+ }
+
r.HandleFunc("/", rootPage).Methods(http.MethodGet)
r.HandleFunc("/nav", navPage).Methods(http.MethodGet)
r.HandleFunc("/signin", signinPage).Methods(http.MethodGet)
@@ -840,6 +852,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
r.HandleFunc("/fluoride/unlike/{id}", fUnlike).Methods(http.MethodPost)
r.HandleFunc("/fluoride/retweet/{id}", fRetweet).Methods(http.MethodPost)
r.HandleFunc("/fluoride/unretweet/{id}", fUnretweet).Methods(http.MethodPost)
+ r.HandleFunc("/fluoride/status/{id}", statusPopup).Methods(http.MethodGet)
r.PathPrefix("/static").Handler(http.StripPrefix("/static",
http.FileServer(http.Dir(staticDir))))