From 73f01ad8d813505c6309fe568d0abc597cff8790 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 18 Feb 2017 23:10:22 +0100 Subject: Add REST API support --- gateway/gateway.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gateway') diff --git a/gateway/gateway.go b/gateway/gateway.go index f965f8a6..5e85926e 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -86,6 +86,7 @@ func (gw *Gateway) handleReceive() { } } if !gw.ignoreMessage(&msg) { + msg.Timestamp = time.Now() for _, br := range gw.Bridges { gw.handleMessage(msg, br) } @@ -165,6 +166,10 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) { } log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel) gw.modifyUsername(&msg, dest) + // for api we need originchannel as channel + if dest.Protocol == "api" { + msg.Channel = originchannel + } err := dest.Send(msg) if err != nil { fmt.Println(err) @@ -199,6 +204,7 @@ func (gw *Gateway) modifyMessage(msg *config.Message, dest *bridge.Bridge) { func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) { br := gw.Bridges[msg.Account] + msg.Protocol = br.Protocol nick := gw.Config.General.RemoteNickFormat if nick == "" { nick = dest.Config.RemoteNickFormat -- cgit v1.2.3