diff options
author | Wim <wim@42.be> | 2018-02-20 18:36:44 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-02-20 18:36:44 +0100 |
commit | f2efc06d1ffaef74407bcb1bdff33bcaf6c52dfe (patch) | |
tree | f8f64d76c7665c4870366d99221624da9ae4bae0 /bridge/api | |
parent | a2b94452db3ac38e0591938bea1ec9df03c433e0 (diff) | |
download | matterbridge-msglm-f2efc06d1ffaef74407bcb1bdff33bcaf6c52dfe.tar.gz matterbridge-msglm-f2efc06d1ffaef74407bcb1bdff33bcaf6c52dfe.tar.bz2 matterbridge-msglm-f2efc06d1ffaef74407bcb1bdff33bcaf6c52dfe.zip |
Give api access to whole config.Message (and events). Closes #374
Diffstat (limited to 'bridge/api')
-rw-r--r-- | bridge/api/api.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/bridge/api/api.go b/bridge/api/api.go index 45bc11d3..2fd7feba 100644 --- a/bridge/api/api.go +++ b/bridge/api/api.go @@ -76,21 +76,18 @@ func (b *Api) Send(msg config.Message) (string, error) { } func (b *Api) handlePostMessage(c echo.Context) error { - message := &ApiMessage{} - if err := c.Bind(message); err != nil { + message := config.Message{} + if err := c.Bind(&message); err != nil { return err } + // these values are fixed + message.Channel = "api" + message.Protocol = "api" + message.Account = b.Account + message.ID = "" + message.Timestamp = time.Now() flog.Debugf("Sending message from %s on %s to gateway", message.Username, "api") - b.Remote <- config.Message{ - Text: message.Text, - Username: message.Username, - UserID: message.UserID, - Channel: "api", - Avatar: message.Avatar, - Account: b.Account, - Gateway: message.Gateway, - Protocol: "api", - } + b.Remote <- message return c.JSON(http.StatusOK, message) } |