2020-10-30 10:23:30 +13:00
|
|
|
package room
|
2020-11-01 00:35:02 +13:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2020-11-15 05:51:18 +13:00
|
|
|
"demodesk/neko/internal/utils"
|
2020-11-01 00:35:02 +13:00
|
|
|
)
|
|
|
|
|
|
|
|
type ClipboardData struct {
|
|
|
|
Text string `json:"text"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *RoomHandler) ClipboardRead(w http.ResponseWriter, r *http.Request) {
|
|
|
|
// TODO: error check?
|
2020-11-02 04:54:06 +13:00
|
|
|
text := h.desktop.ReadClipboard()
|
2020-11-01 00:35:02 +13:00
|
|
|
|
2020-11-15 05:51:18 +13:00
|
|
|
utils.HttpSuccess(w, ClipboardData{
|
2020-11-01 00:35:02 +13:00
|
|
|
Text: text,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *RoomHandler) ClipboardWrite(w http.ResponseWriter, r *http.Request) {
|
|
|
|
data := &ClipboardData{}
|
2020-11-15 05:51:18 +13:00
|
|
|
if !utils.HttpJsonRequest(w, r, data) {
|
2020-11-01 00:35:02 +13:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: error check?
|
2020-11-02 04:54:06 +13:00
|
|
|
h.desktop.WriteClipboard(data.Text)
|
2020-11-15 05:51:18 +13:00
|
|
|
utils.HttpSuccess(w)
|
2020-11-01 00:35:02 +13:00
|
|
|
}
|