Skip to content

Commit

Permalink
updating paused campaign update
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajsoni19 committed Jan 21, 2025
1 parent ced3bfa commit c081c83
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 402 deletions.
7 changes: 4 additions & 3 deletions cmd/campaigns.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ func handleUpdateCampaignArchive(c echo.Context) error {
return c.JSON(http.StatusOK, okResp{req})
}

// handleUpdateCampaignWindow handles campaign window modification
func handleUpdateCampaignWindow(c echo.Context) error {
// handleUpdateCampaignPaused handles campaign update in paused state
func handleUpdateCampaignPaused(c echo.Context) error {
var (
app = c.Get("app").(*App)
id, _ = strconv.Atoi(c.Param("id"))
Expand All @@ -350,14 +350,15 @@ func handleUpdateCampaignWindow(c echo.Context) error {
SlidingWindow bool `json:"sliding_window"`
SlidingWindowRate int `json:"sliding_window_rate"`
SlidingWindowDuration string `json:"sliding_window_duration"`
Messenger string `json:"messenger"`
}{}

// Get and validate fields.
if err := c.Bind(&req); err != nil {
return err
}

if err := app.core.UpdateCampaignWindow(id, req.SlidingWindow, req.SlidingWindowRate, req.SlidingWindowDuration); err != nil {
if err := app.core.UpdateCampaignPaused(id, req.SlidingWindow, req.SlidingWindowRate, req.SlidingWindowDuration, req.Messenger); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func initHTTPHandlers(e *echo.Echo, app *App) {
api.PUT("/api/campaigns/:id", pm(handleUpdateCampaign, "campaigns:manage"))
api.PUT("/api/campaigns/:id/status", pm(handleUpdateCampaignStatus, "campaigns:manage"))
api.PUT("/api/campaigns/:id/archive", pm(handleUpdateCampaignArchive, "campaigns:manage"))
api.PUT("/api/campaigns/:id/window", pm(handleUpdateCampaignWindow, "campaigns:manage"))
api.PUT("/api/campaigns/:id/paused", pm(handleUpdateCampaignPaused, "campaigns:manage"))
api.DELETE("/api/campaigns/:id", pm(handleDeleteCampaign, "campaigns:manage"))

api.GET("/api/media", pm(handleGetMedia, "media:get"))
Expand Down
Loading

0 comments on commit c081c83

Please sign in to comment.