2020-10-29 22:23:30 +01:00
|
|
|
package room
|
2020-10-31 12:35:02 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2020-11-14 17:51:18 +01:00
|
|
|
"demodesk/neko/internal/utils"
|
2020-10-31 12:35:02 +01:00
|
|
|
)
|
|
|
|
|
2020-11-18 21:56:42 +01:00
|
|
|
type ClipboardPayload struct {
|
2020-10-31 12:35:02 +01:00
|
|
|
Text string `json:"text"`
|
|
|
|
}
|
|
|
|
|
2020-11-18 22:35:50 +01:00
|
|
|
func (h *RoomHandler) clipboardRead(w http.ResponseWriter, r *http.Request) {
|
2020-10-31 12:35:02 +01:00
|
|
|
// TODO: error check?
|
2020-11-01 16:54:06 +01:00
|
|
|
text := h.desktop.ReadClipboard()
|
2020-10-31 12:35:02 +01:00
|
|
|
|
2020-11-18 21:56:42 +01:00
|
|
|
utils.HttpSuccess(w, ClipboardPayload{
|
2020-10-31 12:35:02 +01:00
|
|
|
Text: text,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-18 22:35:50 +01:00
|
|
|
func (h *RoomHandler) clipboardWrite(w http.ResponseWriter, r *http.Request) {
|
2020-11-18 21:56:42 +01:00
|
|
|
data := &ClipboardPayload{}
|
2020-11-14 17:51:18 +01:00
|
|
|
if !utils.HttpJsonRequest(w, r, data) {
|
2020-10-31 12:35:02 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: error check?
|
2020-11-01 16:54:06 +01:00
|
|
|
h.desktop.WriteClipboard(data.Text)
|
2020-11-14 17:51:18 +01:00
|
|
|
utils.HttpSuccess(w)
|
2020-10-31 12:35:02 +01:00
|
|
|
}
|