mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 08:21:50 -06:00
feat: add openinapp plugin to open chat links in shared neko instance (#682)
* feat: add openinapp plugin to open chat links in shared neko instance * lint. * feat(openinapp): implement open link handler and route for opening links. * feat(openinapp): switched to http backend and removed example in docker-compose.yaml * lint. --------- Co-authored-by: Miroslav Šedivý <sedivy.miro@gmail.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/m1k1o/neko/server/internal/api/room"
|
||||
"github.com/m1k1o/neko/server/internal/plugins/chat"
|
||||
"github.com/m1k1o/neko/server/internal/plugins/filetransfer"
|
||||
"github.com/m1k1o/neko/server/internal/plugins/openinapp"
|
||||
"github.com/m1k1o/neko/server/pkg/types"
|
||||
"github.com/m1k1o/neko/server/pkg/types/event"
|
||||
"github.com/m1k1o/neko/server/pkg/types/message"
|
||||
@@ -199,6 +200,14 @@ func (s *session) wsToBackend(msg []byte) error {
|
||||
case oldEvent.FILETRANSFER_REFRESH:
|
||||
return s.toBackend(filetransfer.FILETRANSFER_UPDATE, nil)
|
||||
|
||||
// Open In App Events
|
||||
case openinapp.OPENINAPP_OPENLINK:
|
||||
request := &openinapp.Url{}
|
||||
if err := json.Unmarshal(msg, request); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.apiReq(http.MethodPost, "/api/openinapp/openlink", request, nil)
|
||||
|
||||
// Screen Events
|
||||
case oldEvent.SCREEN_RESOLUTION:
|
||||
response := &types.ScreenSize{}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/m1k1o/neko/server/internal/plugins/chat"
|
||||
"github.com/m1k1o/neko/server/internal/plugins/filetransfer"
|
||||
"github.com/m1k1o/neko/server/internal/plugins/openinapp"
|
||||
"github.com/m1k1o/neko/server/pkg/types"
|
||||
"github.com/m1k1o/neko/server/pkg/types/event"
|
||||
"github.com/m1k1o/neko/server/pkg/types/message"
|
||||
@@ -615,6 +616,21 @@ func (s *session) wsToClient(msg []byte) error {
|
||||
Files: files,
|
||||
})
|
||||
|
||||
// Open In App Events
|
||||
case openinapp.OPENINAPP_INIT:
|
||||
request := &openinapp.Init{}
|
||||
if err := json.Unmarshal(data.Payload, request); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.toClient(&struct {
|
||||
Event string `json:"event"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}{
|
||||
Event: openinapp.OPENINAPP_INIT,
|
||||
Enabled: request.Enabled,
|
||||
})
|
||||
|
||||
|
||||
// Screen Events
|
||||
case event.SCREEN_UPDATED:
|
||||
request := &message.ScreenSizeUpdate{}
|
||||
|
||||
Reference in New Issue
Block a user