chore: build
This commit is contained in:
@@ -24,11 +24,11 @@ func (d *Database) NotifyClient(username string, commandID int, notifType, messa
|
||||
Redis.LPush(RedisCtx, notifKey, notifJSON)
|
||||
Redis.Expire(RedisCtx, notifKey, 7*24*time.Hour)
|
||||
|
||||
if services.LBTelegram != nil && services.LBTelegram.IsConfigured() && services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
|
||||
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
|
||||
if chatID, ok, err := d.GetClientTelegramChatID(username); err == nil && ok {
|
||||
go func(id int64, msg string) {
|
||||
if err := services.LBTelegram.SendNotification(id, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", msg)); err != nil {
|
||||
log.Printf("⚠️ [LB] notification client échouée pour %s: %v", username, err)
|
||||
if err := services.TelegramBot.SendNotif(id, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", msg)); err != nil {
|
||||
log.Printf("⚠️ [NOTIF] notification client échouée pour %s: %v", username, err)
|
||||
}
|
||||
}(chatID, message)
|
||||
}
|
||||
@@ -54,11 +54,11 @@ func (d *Database) NotifyLivreur(username string, commandID int, notifType, mess
|
||||
Redis.LPush(RedisCtx, notifKey, notifJSON)
|
||||
Redis.Expire(RedisCtx, notifKey, 7*24*time.Hour)
|
||||
|
||||
if services.LBTelegram != nil && services.LBTelegram.IsConfigured() && services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
|
||||
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
|
||||
if chatID, ok, err := d.GetUserTelegramChatID(username); err == nil && ok {
|
||||
go func(id int64, msg string) {
|
||||
if err := services.LBTelegram.SendNotification(id, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", msg)); err != nil {
|
||||
log.Printf("⚠️ [LB] notification livreur échouée pour %s: %v", username, err)
|
||||
if err := services.TelegramBot.SendNotif(id, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", msg)); err != nil {
|
||||
log.Printf("⚠️ [NOTIF] notification livreur échouée pour %s: %v", username, err)
|
||||
}
|
||||
}(chatID, message)
|
||||
}
|
||||
@@ -95,13 +95,13 @@ func (d *Database) NotifyAllAdminCabine(commandID int, clientUsername, deliveryA
|
||||
Redis.LPush(RedisCtx, notifKey, notifJSON)
|
||||
Redis.Expire(RedisCtx, notifKey, 7*24*time.Hour)
|
||||
|
||||
if services.LBTelegram != nil && services.LBTelegram.IsConfigured() && services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
|
||||
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
|
||||
if chatID, ok, err := d.GetUserTelegramChatID(u.Username); err == nil && ok {
|
||||
capturedChatID := chatID
|
||||
capturedMsg := msg
|
||||
go func(id int64, m string) {
|
||||
if err := services.LBTelegram.SendNotification(id, fmt.Sprintf("🔔 <b>Nouvelle commande</b>\n\n%s", m)); err != nil {
|
||||
log.Printf("⚠️ [LB] notification admin/cabine échouée: %v", err)
|
||||
if err := services.TelegramBot.SendNotif(id, fmt.Sprintf("🔔 <b>Nouvelle commande</b>\n\n%s", m)); err != nil {
|
||||
log.Printf("⚠️ [NOTIF] notification admin/cabine échouée: %v", err)
|
||||
}
|
||||
}(capturedChatID, capturedMsg)
|
||||
}
|
||||
@@ -138,13 +138,13 @@ func (d *Database) NotifyAllAdminCabineAlert(alertID int, livreurUsername, alert
|
||||
Redis.LPush(RedisCtx, notifKey, notifJSON)
|
||||
Redis.Expire(RedisCtx, notifKey, 7*24*time.Hour)
|
||||
|
||||
if services.LBTelegram != nil && services.LBTelegram.IsConfigured() && services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
|
||||
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
|
||||
if chatID, ok, err := d.GetUserTelegramChatID(u.Username); err == nil && ok {
|
||||
capturedChatID := chatID
|
||||
capturedBody := body
|
||||
go func(id int64, m string) {
|
||||
if err := services.LBTelegram.SendNotification(id, fmt.Sprintf("🚨 <b>Alerte livreur</b>\n\n%s", m)); err != nil {
|
||||
log.Printf("⚠️ [LB] notification alerte échouée: %v", err)
|
||||
if err := services.TelegramBot.SendNotif(id, fmt.Sprintf("🚨 <b>Alerte livreur</b>\n\n%s", m)); err != nil {
|
||||
log.Printf("⚠️ [NOTIF] notification alerte échouée: %v", err)
|
||||
}
|
||||
}(capturedChatID, capturedBody)
|
||||
}
|
||||
|
||||
@@ -154,6 +154,11 @@ func (d *Database) GetSettings() (models.AppSettings, error) {
|
||||
settings.TelegramBotUsername = row.Value
|
||||
case "telegram_notifications_enabled":
|
||||
settings.TelegramNotificationsEnabled = row.Value == "true"
|
||||
case "telegram_notif_bots":
|
||||
var bots []models.TelegramBotConfig
|
||||
if err := json.Unmarshal([]byte(row.Value), &bots); err == nil {
|
||||
settings.TelegramNotifBots = bots
|
||||
}
|
||||
case "delivery_mode":
|
||||
var mode models.DeliveryModeConfig
|
||||
if err := json.Unmarshal([]byte(row.Value), &mode); err == nil {
|
||||
@@ -249,6 +254,13 @@ func (d *Database) UpdateSettings(s models.AppSettings) error {
|
||||
{"telegram_bot_token", s.TelegramBotToken},
|
||||
{"telegram_bot_username", s.TelegramBotUsername},
|
||||
{"telegram_notifications_enabled", boolStr(s.TelegramNotificationsEnabled)},
|
||||
{"telegram_notif_bots", func() string {
|
||||
if s.TelegramNotifBots == nil {
|
||||
s.TelegramNotifBots = []models.TelegramBotConfig{}
|
||||
}
|
||||
b, _ := json.Marshal(s.TelegramNotifBots)
|
||||
return string(b)
|
||||
}()},
|
||||
{"telegram_2fa_enabled", boolStr(s.Telegram2FAEnabled)},
|
||||
{"delivery_mode", string(deliveryModeJSON)},
|
||||
{"shop_name", s.ShopName},
|
||||
|
||||
Reference in New Issue
Block a user