Skip to content

Commit 7984413

Browse files
committed
♻️ refactor: update codebase #2
1 parent a8501a5 commit 7984413

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

internal/core/core.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (c *CoreCommand) snap(args []string) error {
178178
}
179179

180180
func (c *CoreCommand) notify() {
181-
conf, err := syncconf.Conf.FindTelegramSeeker(constant.TelegramKeyTenant1)
181+
conf, err := syncconf.Conf.FindTelegramSeeker(constant.TelegramKey001)
182182
if err != nil {
183183
logger.Errorf("Telegram Bot Notify", err)
184184
return
@@ -194,11 +194,11 @@ func (c *CoreCommand) notify() {
194194

195195
func (c *CoreCommand) sendNotify(topic string, status dbx.Dbx, conf telegram.MultiTenantTelegramConfig) {
196196
var builder strings.Builder
197-
icon, _ := blueprint.TypeIcons[blueprint.TypeSuccess]
197+
icon := blueprint.TypeIcons[blueprint.TypeSuccess]
198198
if !status.IsConnected {
199-
icon, _ = blueprint.TypeIcons[blueprint.TypeError]
199+
icon = blueprint.TypeIcons[blueprint.TypeError]
200200
}
201-
timestamp := timex.With(time.Now()).Format(timex.DateTimeFormYearMonthDayHourMinuteSecond)
201+
timestamp := timex.With(time.Now()).Format(timex.TimeFormat20060102150405)
202202
builder.WriteString(fmt.Sprintf("%v %s\n", icon, topic))
203203
builder.WriteString(fmt.Sprintf("tz: `%s`\n\n", timestamp))
204204
builder.WriteString(fmt.Sprintf("connected: `%v`\n", status.IsConnected))

internal/middlewares/errors_middleware.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import (
1818
func (m *MiddlewareManager) ErrorMiddleware(c *gin.Context) {
1919
defer func() {
2020
if err := recover(); err != nil {
21-
logger.Debugf("Recovered errors from panic:", err)
21+
logger.Debugf("Recovered errors from panic: %v", err)
2222
m.defaultHandleRecovery(c, err)
2323
return
2424
}
2525
if len(c.Errors) > 0 {
26-
logger.Debugf("Business logic errors:", c.Errors)
26+
logger.Debugf("Business logic errors: %v", c.Errors)
2727
response := entity.NewResponseEntity().BadRequest(http.StatusText(http.StatusBadRequest), nil)
2828
response.SetErrors(fmt.Sprint(c.Errors))
2929
m.notification(c, c.Errors, response.StatusCode)
@@ -46,7 +46,7 @@ func (m *MiddlewareManager) notification(c *gin.Context, err any, status int) {
4646
builder.WriteString(fmt.Sprintf("Status Code: %d\n", status))
4747
builder.WriteString(fmt.Sprintf("Message: %s\n", http.StatusText(status)))
4848
builder.WriteString(fmt.Sprintf("Error(R): `%s`\n", fmt.Sprint(err)))
49-
conf, e := m.conf.FindTelegramSeeker(constant.TelegramKeyTenant2)
49+
conf, e := m.conf.FindTelegramSeeker(constant.TelegramKey002)
5050
if e != nil {
5151
return
5252
}

internal/middlewares/interceptor_middleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (m *MiddlewareManager) console(c *gin.Context, response *responseWriterWrap
7272
}
7373

7474
func (m *MiddlewareManager) notify(c *gin.Context, response *responseWriterWrapper, timestamp string, raw []byte, err error) {
75-
conf, _err := m.conf.FindTelegramSeeker(constant.TelegramKeyTenant1)
75+
conf, _err := m.conf.FindTelegramSeeker(constant.TelegramKey001)
7676
if _err != nil {
7777
logger.Errorf("Telegram Bot Notify", _err)
7878
return

pkg/constant/const.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package constant
22

33
const (
4-
TelegramKeyTenant1 = "core_status"
5-
TelegramKeyTenant2 = "core_recovery"
4+
TelegramKey001 = "core_status"
5+
TelegramKey002 = "core_recovery"
66
)

0 commit comments

Comments
 (0)