Skip to content

Commit

Permalink
check env before tg send
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
sorokinmax committed Feb 28, 2024
1 parent d723e68 commit e267540
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions internal/api/private.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ func PostApkHandler(ctx *gin.Context) {

app := apk.ApkProcessor("./apps", file.Filename)

msg := fmt.Sprintf("New build %s %s is ready", app.AppLabel, app.VersionName)
telegram.TgSendMessage(globals.Config.BotToken, msg, globals.Config.ChatID)
if globals.Config.BotToken != "" && globals.Config.ChatID != 0 {
msg := fmt.Sprintf("New build %s %s is ready", app.AppLabel, app.VersionName)
telegram.TgSendMessage(globals.Config.BotToken, msg, globals.Config.ChatID)
}
ctx.JSON(http.StatusOK, gin.H{"responce": "File processed"})
}
6 changes: 3 additions & 3 deletions internal/globals/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package globals
// SERVICE DESCRIPTION
const ServiceFriendlyName = "Android store"
const ServiceName = "android-store"
const Version = "v.1.1.0"
const Version = "1.1.1"

// ENVIRONMENT VARIABLES CONFIGURATION STRUCTURE
type ConfigStruct struct {
HttpPort uint `env:"AS_HTTP_PORT" envDefault:"80"`
Url string `env:"AS_HTTP_PORT" envDefault:"http://localhost:80"`
BotToken string `env:"TELEGRAM_BOT_TOKEN"`
ChatID int `env:"TELEGRAM_CHAT_ID"`
BotToken string `env:"TELEGRAM_BOT_TOKEN" envDefault:""`
ChatID int `env:"TELEGRAM_CHAT_ID" envDefault:0`
}

// GLOBAL VARIABLES
Expand Down

0 comments on commit e267540

Please sign in to comment.