Add/Show/Delete Emojis on Notes (#181)

This MR adds the ability to view, add, and delete emojis from notes and comments.

This action can be performed by default with the `Ea` (emoji add) keybinding, and the `Ed` (emoji delete) keybinding. Only emojis added by the current user are eligible for deletion. The MR also implements a popup functionality which shows the user who added emojis on hover.

Implements #179
This commit is contained in:
Harrison (Harry) Cramer
2024-02-18 21:16:53 -05:00
committed by GitHub
parent 99741178f9
commit baee20b279
22 changed files with 11655 additions and 83 deletions

47
cmd/user.go Normal file
View File

@@ -0,0 +1,47 @@
package main
import (
"encoding/json"
"net/http"
"github.com/xanzy/go-gitlab"
)
type UserResponse struct {
SuccessResponse
User *gitlab.User `json:"user"`
}
func (a *api) meHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
if r.Method != http.MethodGet {
w.Header().Set("Access-Control-Allow-Methods", http.MethodGet)
handleError(w, InvalidRequestError{}, "Expected GET", http.StatusMethodNotAllowed)
return
}
user, res, err := a.client.CurrentUser()
if err != nil {
handleError(w, err, "Failed to get current user", http.StatusInternalServerError)
return
}
if res.StatusCode >= 300 {
handleError(w, err, "User API returned non-200 status", res.StatusCode)
return
}
response := UserResponse{
SuccessResponse: SuccessResponse{
Message: "User fetched successfully",
Status: http.StatusOK,
},
User: user,
}
err = json.NewEncoder(w).Encode(response)
if err != nil {
handleError(w, err, "Could not encode response", http.StatusInternalServerError)
}
}