Auto-sync permit competitors in monitoring PF
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 35s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 35s
This commit is contained in:
@@ -352,13 +352,45 @@ func (s Server) listingItem(w http.ResponseWriter, r *http.Request, path string)
|
||||
writeError(w, http.StatusMethodNotAllowed, "method not allowed")
|
||||
return
|
||||
}
|
||||
if err := s.App.DeleteListing(r.Context(), emp.ID, id); err != nil {
|
||||
deleted, err := s.App.DeleteListing(r.Context(), emp.ID, id)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusNotFound, "listing not found")
|
||||
return
|
||||
}
|
||||
if deleted.OwnerChatID != nil && *deleted.OwnerChatID != "" {
|
||||
_ = s.App.TG.SendMessage(r.Context(), *deleted.OwnerChatID, formatDeletedListingMessage(deleted))
|
||||
}
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func formatDeletedListingMessage(deleted *DeletedListing) string {
|
||||
listing := deleted.Listing
|
||||
title := "без названия"
|
||||
if listing.Title != nil && *listing.Title != "" {
|
||||
title = *listing.Title
|
||||
}
|
||||
price := "—"
|
||||
if listing.CurrentPrice != nil {
|
||||
currency := "AED"
|
||||
if listing.Currency != nil && *listing.Currency != "" {
|
||||
currency = *listing.Currency
|
||||
}
|
||||
price = strconv.FormatFloat(*listing.CurrentPrice, 'f', 0, 64) + " " + currency
|
||||
}
|
||||
permit := "—"
|
||||
if listing.PermitNumber != nil && *listing.PermitNumber != "" {
|
||||
permit = *listing.PermitNumber
|
||||
}
|
||||
return "🏠 <b>" + deleted.ProjectTitle + "</b>\n" +
|
||||
"Тип: " + deleted.ProjectDeal + " · Изменений: 1\n" +
|
||||
"——————————\n" +
|
||||
"🗑️ <b>Удален конкурент</b> — " + listing.Source + "\n" +
|
||||
title + "\n" +
|
||||
"Последняя цена: " + price + "\n" +
|
||||
"Permit: <code>" + permit + "</code>\n" +
|
||||
listing.URL
|
||||
}
|
||||
|
||||
func (s Server) requireEmployee(w http.ResponseWriter, r *http.Request) (*Employee, bool) {
|
||||
emp, err := s.App.CurrentEmployee(r.Context(), portalUserID(r), true)
|
||||
if errors.Is(err, ErrTelegramRequired) {
|
||||
|
||||
Reference in New Issue
Block a user