From 7803242588461c6f71b4da6076869b1cf56523fe Mon Sep 17 00:00:00 2001 From: Vladimir Hodakov Date: Sun, 26 Nov 2017 17:44:41 +0400 Subject: [PATCH] Bastion chat is covered by orders now --- lib/orders/orders.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/orders/orders.go b/lib/orders/orders.go index 22b8810..f3a5573 100644 --- a/lib/orders/orders.go +++ b/lib/orders/orders.go @@ -33,11 +33,35 @@ func (o *Orders) sendOrder(order *dbmapping.Order) string { if !ok { return "fail" } + + // Adding Bastion chat as it's the zero chat + bastionGroupID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64) + bastionChat := dbmapping.Chat{} + err := c.Db.Get(&bastionChat, c.Db.Rebind("SELECT * FROM chats WHERE telegram_id=?"), bastionGroupID) + if err != nil { + return "fail" + } + + targetChats = append(targetChats, bastionChat) } else { targetChats, ok = c.Squader.GetSquadChatsBySquadsIDs(order.TargetSquads) if !ok { return "fail" } + + targetChatsIDs := strings.Split(order.TargetSquads, ",") + for i := range targetChatsIDs { + if targetChatsIDs[i] == "0" { + bastionGroupID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64) + bastionChat := dbmapping.Chat{} + err := c.Db.Get(&bastionChat, c.Db.Rebind("SELECT * FROM chats WHERE telegram_id=?"), bastionGroupID) + if err != nil { + return "fail" + } + + targetChats = append(targetChats, bastionChat) + } + } } for i := range targetChats {