mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-28 11:16:37 +08:00
c0d743d89d
Fixes #66
23 lines
501 B
Go
23 lines
501 B
Go
package handler
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/ShukeBta/MediaStationGo/internal/service"
|
|
)
|
|
|
|
func writeSubscriptionConflict(c *gin.Context, err error) bool {
|
|
if !errors.Is(err, service.ErrSubscriptionAlreadyExists) {
|
|
return false
|
|
}
|
|
body := gin.H{"error": "subscription already exists"}
|
|
if existingID := service.SubscriptionAlreadyExistsID(err); existingID != "" {
|
|
body["existing_id"] = existingID
|
|
}
|
|
c.JSON(http.StatusConflict, body)
|
|
return true
|
|
}
|