neo workflow
This commit is contained in:
@@ -176,7 +176,7 @@ func (o *CollaborativeAreaController) RemovePeer() {
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
shared := r.ToCollaborativeArea()
|
||||
newPeers := map[string][]string{}
|
||||
if shared.CreatorID != id2 {
|
||||
if shared.CreatorID == id2 {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
"code": 409,
|
||||
@@ -277,7 +277,12 @@ func (o *CollaborativeAreaController) AddWorkflow() {
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).LoadOne(id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
if r.Code != 200 {
|
||||
o.Data["json"] = r
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
shared := r.ToCollaborativeArea()
|
||||
if shared != nil && !slices.Contains(shared.Workflows, id2) {
|
||||
shared.Workflows = append(shared.Workflows, id2)
|
||||
@@ -291,9 +296,12 @@ func (o *CollaborativeAreaController) AddWorkflow() {
|
||||
// @Description find shared workspace by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Param id2 path string true "the id you want to add"
|
||||
// @Param body body models.workspace true "The shared workspace content"
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/peer/:id2 [post]
|
||||
func (o *CollaborativeAreaController) AddPeer() {
|
||||
var res []string
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
@@ -301,22 +309,16 @@ func (o *CollaborativeAreaController) AddPeer() {
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
shared := r.ToCollaborativeArea()
|
||||
if shared.AllowedPeersGroup != nil {
|
||||
keys := make([]string, len(shared.AllowedPeersGroup))
|
||||
i := 0
|
||||
for k := range shared.AllowedPeersGroup {
|
||||
keys[i] = k
|
||||
i++
|
||||
}
|
||||
if shared != nil && !slices.Contains(keys, id2) {
|
||||
if config.GetConfig().Whitelist {
|
||||
shared.AllowedPeersGroup[id2] = []string{"*"}
|
||||
} else {
|
||||
shared.AllowedPeersGroup[id2] = []string{}
|
||||
}
|
||||
}
|
||||
if shared.AllowedPeersGroup == nil {
|
||||
shared.AllowedPeersGroup = map[string][]string{}
|
||||
}
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(shared.Serialize(shared), id)
|
||||
if config.GetConfig().Whitelist && len(res) == 0 {
|
||||
shared.AllowedPeersGroup[id2] = []string{"*"}
|
||||
} else {
|
||||
shared.AllowedPeersGroup[id2] = res
|
||||
}
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
|
||||
shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user