fix: add tg notification for put file
This commit is contained in:
parent
187e96a3ad
commit
3e4707ac80
@ -933,6 +933,45 @@ func (h *Heruvym) PutFile(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ctx := r.Context()
|
||||||
|
domain := ctx.Value(middleware.HostKey).(string)
|
||||||
|
if domain == "" {
|
||||||
|
fmt.Println("domain is nil err")
|
||||||
|
}
|
||||||
|
role := jwt_adapter.GetRole(ctx)
|
||||||
|
go func() {
|
||||||
|
if sess.Id != "" && role != "admin" {
|
||||||
|
if err == nil && h.notifier != nil {
|
||||||
|
var userLink, supportLink string
|
||||||
|
if sess.StandardClaims.Issuer != "" {
|
||||||
|
fmt.Println("MABNAT", domain)
|
||||||
|
if domain[0] == 's' {
|
||||||
|
userLink = fmt.Sprintf("https://sadmin.pena/users/%s", sess.Id)
|
||||||
|
supportLink = fmt.Sprintf("https://sadmin.pena/support/%s", req.Ticket)
|
||||||
|
} else {
|
||||||
|
userLink = fmt.Sprintf("https://admin.pena/users/%s", sess.Id)
|
||||||
|
supportLink = fmt.Sprintf("https://admin.pena/support/%s", req.Ticket)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if domain[0] == 's' {
|
||||||
|
supportLink = fmt.Sprintf("https://sadmin.pena/support/%s", req.Ticket)
|
||||||
|
} else {
|
||||||
|
supportLink = fmt.Sprintf("https://admin.pena/support/%s", req.Ticket)
|
||||||
|
}
|
||||||
|
userLink = "незарегистрированного пользователя"
|
||||||
|
}
|
||||||
|
|
||||||
|
message := fmt.Sprintf("Вам пришло сообщение от %s сссылка на пользователя с %s, ccылка на чат - %s",
|
||||||
|
userLink, domain, supportLink)
|
||||||
|
|
||||||
|
if _, err := h.notifier.Send(tb.ChatID(h.tgChatID), message); err != nil {
|
||||||
|
fmt.Println("CAN NOT NOTIFY", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
|
||||||
if _, err := w.Write(resp); err != nil {
|
if _, err := w.Write(resp); err != nil {
|
||||||
fmt.Println("CAN NOT WRITE", err)
|
fmt.Println("CAN NOT WRITE", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user