4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 14:19:24 +00:00

Allow reuse of api in different gateways. See #189

This commit is contained in:
Wim
2017-06-07 23:54:50 +02:00
parent ad3cb0386b
commit 359d0f2910
2 changed files with 20 additions and 5 deletions

View File

@ -22,6 +22,7 @@ type ApiMessage struct {
Text string `json:"text"`
Username string `json:"username"`
Avatar string `json:"avatar"`
Gateway string `json:"gateway"`
}
var flog *log.Entry
@ -76,12 +77,15 @@ func (b *Api) handlePostMessage(c echo.Context) error {
if err := c.Bind(message); err != nil {
return err
}
flog.Debugf("Sending message from %s on %s to gateway", message.Username, "api")
b.Remote <- config.Message{
Text: message.Text,
Username: message.Username,
Channel: "api",
Avatar: message.Avatar,
Account: b.Account,
Gateway: message.Gateway,
Protocol: "api",
}
return c.JSON(http.StatusOK, message)
}