✨ Able to transfer story / article between realms
This commit is contained in:
parent
0383cdf407
commit
fca4032031
@ -113,6 +113,7 @@ func editArticle(c *fiber.Ctx) error {
|
||||
InvisibleUsers []uint `json:"invisible_users_list"`
|
||||
Visibility *int8 `json:"visibility"`
|
||||
IsDraft bool `json:"is_draft"`
|
||||
RealmAlias *string `json:"realm"`
|
||||
}
|
||||
|
||||
if err := exts.BindAndValidate(c, &data); err != nil {
|
||||
@ -165,6 +166,16 @@ func editArticle(c *fiber.Ctx) error {
|
||||
item.Visibility = *data.Visibility
|
||||
}
|
||||
|
||||
if data.RealmAlias != nil {
|
||||
if realm, err := services.GetRealmWithAlias(*data.RealmAlias); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else if _, err = services.GetRealmMember(realm.ExternalID, user.ExternalID); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to post in the realm, access denied: %v", err))
|
||||
} else {
|
||||
item.RealmID = &realm.ID
|
||||
}
|
||||
}
|
||||
|
||||
if item, err := services.EditPost(item); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
|
@ -132,6 +132,7 @@ func editStory(c *fiber.Ctx) error {
|
||||
InvisibleUsers []uint `json:"invisible_users_list"`
|
||||
Visibility *int8 `json:"visibility"`
|
||||
IsDraft bool `json:"is_draft"`
|
||||
RealmAlias *string `json:"realm"`
|
||||
}
|
||||
|
||||
if err := exts.BindAndValidate(c, &data); err != nil {
|
||||
@ -184,6 +185,16 @@ func editStory(c *fiber.Ctx) error {
|
||||
item.Visibility = *data.Visibility
|
||||
}
|
||||
|
||||
if data.RealmAlias != nil {
|
||||
if realm, err := services.GetRealmWithAlias(*data.RealmAlias); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else if _, err = services.GetRealmMember(realm.ExternalID, user.ExternalID); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to post in the realm, access denied: %v", err))
|
||||
} else {
|
||||
item.RealmID = &realm.ID
|
||||
}
|
||||
}
|
||||
|
||||
if item, err := services.EditPost(item); err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user