Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,22 @@ func (app *App) BlindTransferCallToQueue(ctx context.Context, domainId int64, re
})
}

func (app *App) BlindTransferCallToDialplan(ctx context.Context, domainId int64, req *model.BlindTransferCallToDialplan) model.AppError {
if req.Variables == nil {
req.Variables = make(map[string]string)
}

s := strconv.Itoa(req.SchemaId)

req.Variables["transfer_to_schema_id"] = s

return app.BlindTransferCallExt(ctx, domainId, &model.BlindTransferCall{
UserCallRequest: req.UserCallRequest,
Destination: s,
Variables: req.Variables,
})
}

func (app *App) BlindTransferCall(ctx context.Context, domainId int64, req *model.BlindTransferCall) model.AppError {
var cli call_manager.CallClient
var err model.AppError
Expand Down
1 change: 1 addition & 0 deletions app/flow_routing_out_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (app *App) UpdateRoutingOutboundCall(ctx context.Context, routing *model.Ro
oldRouting.Description = routing.Description
oldRouting.Pattern = routing.Pattern
oldRouting.Disabled = routing.Disabled
oldRouting.AllowTransfer = routing.AllowTransfer
oldRouting.UpdatedAt = routing.UpdatedAt

if routing.GetSchemaId() != nil {
Expand Down
9 changes: 9 additions & 0 deletions controller/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ func (c *Controller) BlindTransferCallToQueue(ctx context.Context, session *auth
return c.app.BlindTransferCallToQueue(ctx, session.Domain(domainId), req)
}

func (c *Controller) BlindTransferCallToDialplan(ctx context.Context, session *auth_manager.Session, domainId int64, req *model.BlindTransferCallToDialplan) model.AppError {
permission := session.GetPermission(model.PERMISSION_SCOPE_CALL)
if !permission.CanUpdate() {
return c.app.MakePermissionError(session, permission, auth_manager.PERMISSION_ACCESS_UPDATE)
}

return c.app.BlindTransferCallToDialplan(ctx, session.Domain(domainId), req)
}

func (c *Controller) CallToQueue(ctx context.Context, session *auth_manager.Session, userId int64, parentId string, cp model.CallParameters, queueId, agentId *int) (string, model.AppError) {
permission := session.GetPermission(model.PERMISSION_SCOPE_CALL)
if !permission.CanCreate() {
Expand Down
549 changes: 309 additions & 240 deletions gen/engine/acr_routing_out_call.pb.go

Large diffs are not rendered by default.

50 changes: 30 additions & 20 deletions grpc_api/flow_routing_out_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func (api *routingOutboundCall) CreateRoutingOutboundCall(ctx context.Context, i
Schema: model.Lookup{
Id: int(in.GetSchema().GetId()),
},
Disabled: in.Disabled,
Disabled: in.Disabled,
AllowTransfer: in.AllowTransfer,
}

if routing, err = api.ctrl.CreateRoutingOutboundCall(ctx, session, routing); err != nil {
Expand Down Expand Up @@ -75,6 +76,10 @@ func (api *routingOutboundCall) SearchRoutingOutboundCall(ctx context.Context, i
Description: GetStringPointer(in.Description),
}

if in.AllowTransfer != nil {
req.AllowTransfer = model.NewBool(in.GetAllowTransfer().GetValue())
}

list, isEndList, err = api.ctrl.SearchRoutingOutboundCall(ctx, session, req)

if err != nil {
Expand Down Expand Up @@ -130,8 +135,9 @@ func (api *routingOutboundCall) UpdateRoutingOutboundCall(ctx context.Context, i
Schema: model.Lookup{
Id: int(in.GetSchema().GetId()),
},
Pattern: in.Pattern,
Disabled: in.Disabled,
Pattern: in.Pattern,
Disabled: in.Disabled,
AllowTransfer: in.AllowTransfer,
}

routing, err = api.ctrl.UpdateRoutingOutboundCall(ctx, session, routing)
Expand Down Expand Up @@ -165,6 +171,8 @@ func (api *routingOutboundCall) PatchRoutingOutboundCall(ctx context.Context, in
patch.Pattern = model.NewString(in.GetPattern())
case "disabled":
patch.Disabled = model.NewBool(in.GetDisabled())
case "allow_transfer":
patch.AllowTransfer = model.NewBool(in.GetAllowTransfer())
}
}

Expand Down Expand Up @@ -211,16 +219,17 @@ func (api *routingOutboundCall) DeleteRoutingOutboundCall(ctx context.Context, i

func transformRoutingOutboundCall(src *model.RoutingOutboundCall) *engine.RoutingOutboundCall {
dst := &engine.RoutingOutboundCall{
Id: src.Id,
DomainId: src.DomainId,
CreatedAt: src.CreatedAt,
CreatedBy: GetProtoLookup(src.CreatedBy),
UpdatedAt: src.UpdatedAt,
UpdatedBy: GetProtoLookup(src.UpdatedBy),
Description: src.Description,
Name: src.Name,
Pattern: src.Pattern,
Disabled: src.Disabled,
Id: src.Id,
DomainId: src.DomainId,
CreatedAt: src.CreatedAt,
CreatedBy: GetProtoLookup(src.CreatedBy),
UpdatedAt: src.UpdatedAt,
UpdatedBy: GetProtoLookup(src.UpdatedBy),
Description: src.Description,
Name: src.Name,
Pattern: src.Pattern,
Disabled: src.Disabled,
AllowTransfer: src.AllowTransfer,
}

if src.GetSchemaId() != nil {
Expand All @@ -235,13 +244,14 @@ func transformRoutingOutboundCall(src *model.RoutingOutboundCall) *engine.Routin

func toRoutingOutboundCallCompact(src *model.RoutingOutboundCall) *engine.RoutingOutboundCallCompact {
dst := &engine.RoutingOutboundCallCompact{
Id: src.Id,
DomainId: src.DomainId,
Description: src.Description,
Name: src.Name,
Pattern: src.Pattern,
Disabled: src.Disabled,
Position: int32(src.Position),
Id: src.Id,
DomainId: src.DomainId,
Description: src.Description,
Name: src.Name,
Pattern: src.Pattern,
Disabled: src.Disabled,
AllowTransfer: src.AllowTransfer,
Position: int32(src.Position),
}

if src.GetSchemaId() != nil {
Expand Down
6 changes: 6 additions & 0 deletions model/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ type BlindTransferCallToQueue struct {
Variables map[string]string
}

type BlindTransferCallToDialplan struct {
UserCallRequest
SchemaId int
Variables map[string]string
}

type BridgeCall struct {
FromId string `json:"from_id" db:"from_id"`
ToId string `json:"to_id" db:"to_id"`
Expand Down
45 changes: 26 additions & 19 deletions model/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,23 @@ func (r *RoutingVariable) IsValid() AppError {

type RoutingOutboundCall struct {
DomainRecord
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Schema Lookup `json:"schema" db:"schema"`
Position int `json:"position" db:"position"`
Pattern string `json:"pattern" db:"pattern"`
Disabled bool `json:"disabled" db:"disabled"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Schema Lookup `json:"schema" db:"schema"`
Position int `json:"position" db:"position"`
Pattern string `json:"pattern" db:"pattern"`
Disabled bool `json:"disabled" db:"disabled"`
AllowTransfer bool `json:"allow_transfer" db:"allow_transfer"`
}

type SearchRoutingOutboundCall struct {
ListRequest
Ids []uint32
Name *string
SchemaIds []uint32
Pattern *string
Description *string
Ids []uint32
Name *string
SchemaIds []uint32
Pattern *string
Description *string
AllowTransfer *bool
}

func (RoutingOutboundCall) DefaultOrder() string {
Expand All @@ -144,25 +146,26 @@ func (RoutingOutboundCall) DefaultOrder() string {

func (a RoutingOutboundCall) AllowFields() []string {
return []string{"id", "domain_id", "name", "description", "created_at", "created_by", "updated_at", "updated_by",
"pattern", "disabled", "schema", "position"}
"pattern", "disabled", "allow_transfer", "schema", "position"}
}

func (a RoutingOutboundCall) DefaultFields() []string {
return []string{"id", "name", "description",
"pattern", "disabled", "schema", "position"}
"pattern", "disabled", "allow_transfer", "schema", "position"}
}

func (a RoutingOutboundCall) EntityName() string {
return "acr_routing_outbound_call_view"
}

type RoutingOutboundCallPatch struct {
UpdatedById int
Name *string `json:"name" db:"name"`
Description *string `json:"description" db:"description"`
Schema *Lookup `json:"schema" db:"scheme"`
Pattern *string `json:"pattern" db:"pattern"`
Disabled *bool `json:"disabled" db:"disabled"`
UpdatedById int
Name *string `json:"name" db:"name"`
Description *string `json:"description" db:"description"`
Schema *Lookup `json:"schema" db:"scheme"`
Pattern *string `json:"pattern" db:"pattern"`
Disabled *bool `json:"disabled" db:"disabled"`
AllowTransfer *bool `json:"allow_transfer" db:"allow_transfer"`
}

func (r *RoutingOutboundCall) Patch(patch *RoutingOutboundCallPatch) {
Expand All @@ -185,6 +188,10 @@ func (r *RoutingOutboundCall) Patch(patch *RoutingOutboundCallPatch) {
if patch.Disabled != nil {
r.Disabled = *patch.Disabled
}

if patch.AllowTransfer != nil {
r.AllowTransfer = *patch.AllowTransfer
}
}

func (r *RoutingOutboundCall) GetSchemaId() *int {
Expand Down
73 changes: 39 additions & 34 deletions store/sqlstore/flow_routing_out_call_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,29 @@ func (s SqlRoutingOutboundCallStore) Create(ctx context.Context, routing *model.
var out *model.RoutingOutboundCall
err := s.GetMaster().WithContext(ctx).SelectOne(&out, `with tmp as (
insert into flow.acr_routing_outbound_call (domain_id, name, description, created_at, created_by, updated_at, updated_by,
scheme_id, pattern, disabled)
values (:DomainId, :Name, :Description, :CreatedAt, :CreatedBy, :UpdatedAt, :UpdatedBy, :SchemeId, :Pattern, :Disabled)
scheme_id, pattern, disabled, allow_transfer)
values (:DomainId, :Name, :Description, :CreatedAt, :CreatedBy, :UpdatedAt, :UpdatedBy, :SchemeId, :Pattern, :Disabled, :AllowTransfer)
returning *
)
select tmp.id, tmp.domain_id, tmp.name, tmp.description, tmp.created_at, call_center.cc_get_lookup(c.id,c.name) as created_by,
tmp.created_at, call_center.cc_get_lookup(u.id, u.name) as updated_by, tmp.updated_at, call_center.cc_get_lookup(arst.id, arst.name) as schema,
tmp.pattern, disabled
tmp.pattern, disabled, allow_transfer
from tmp
left join directory.wbt_user c on c.id = tmp.created_by
left join directory.wbt_user u on u.id = tmp.updated_by
inner join flow.acr_routing_scheme arst on tmp.scheme_id = arst.id`,
map[string]interface{}{
"DomainId": routing.DomainId,
"Name": routing.Name,
"Description": routing.Description,
"CreatedAt": routing.CreatedAt,
"CreatedBy": routing.CreatedBy.GetSafeId(),
"UpdatedAt": routing.UpdatedAt,
"UpdatedBy": routing.UpdatedBy.GetSafeId(),
"SchemeId": routing.Schema.Id,
"Pattern": routing.Pattern,
"Disabled": routing.Disabled,
"DomainId": routing.DomainId,
"Name": routing.Name,
"Description": routing.Description,
"CreatedAt": routing.CreatedAt,
"CreatedBy": routing.CreatedBy.GetSafeId(),
"UpdatedAt": routing.UpdatedAt,
"UpdatedBy": routing.UpdatedBy.GetSafeId(),
"SchemeId": routing.Schema.Id,
"Pattern": routing.Pattern,
"Disabled": routing.Disabled,
"AllowTransfer": routing.AllowTransfer,
})

if err != nil {
Expand All @@ -65,13 +66,14 @@ func (s SqlRoutingOutboundCallStore) GetAllPage(ctx context.Context, domainId in
var routing []*model.RoutingOutboundCall

f := map[string]interface{}{
"DomainId": domainId,
"Q": search.GetQ(),
"Ids": pq.Array(search.Ids),
"Name": search.Name,
"Description": search.Description,
"SchemaIds": pq.Array(search.SchemaIds),
"Pattern": search.Pattern,
"DomainId": domainId,
"Q": search.GetQ(),
"Ids": pq.Array(search.Ids),
"Name": search.Name,
"Description": search.Description,
"SchemaIds": pq.Array(search.SchemaIds),
"Pattern": search.Pattern,
"AllowTransfer": search.AllowTransfer,
}

err := s.ListQueryFromSchema(ctx, &routing, "flow", search.ListRequest,
Expand All @@ -82,6 +84,7 @@ func (s SqlRoutingOutboundCallStore) GetAllPage(ctx context.Context, domainId in
and (:Name::text isnull or name = :Name)
and (:Description::text isnull or description = :Description)
and (:Pattern::text isnull or pattern = :Pattern)
and (:AllowTransfer::bool isnull or allow_transfer = :AllowTransfer)
`,
model.RoutingOutboundCall{}, f)
if err != nil {
Expand All @@ -96,8 +99,8 @@ func (s SqlRoutingOutboundCallStore) Get(ctx context.Context, domainId, id int64

if err := s.GetReplica().WithContext(ctx).SelectOne(&routing,
`select tmp.id, tmp.domain_id, tmp.name, tmp.description, tmp.created_at, call_center.cc_get_lookup(c.id, c.name) as created_by,
tmp.created_at, call_center.cc_get_lookup(u.id, u.name) as updated_by, call_center.cc_get_lookup(arst.id, arst.name) as schema,
tmp.pattern, disabled
tmp.created_at, call_center.cc_get_lookup(u.id, u.name) as updated_by, call_center.cc_get_lookup(arst.id, arst.name) as schema,
tmp.pattern, disabled, allow_transfer
from flow.acr_routing_outbound_call tmp
left join directory.wbt_user c on c.id = tmp.created_by
left join directory.wbt_user u on u.id = tmp.updated_by
Expand All @@ -123,27 +126,29 @@ func (s SqlRoutingOutboundCallStore) Update(ctx context.Context, routing *model.
updated_by = :UpdatedBy,
scheme_id = :SchemeId,
pattern = :Pattern,
disabled = :Disabled
disabled = :Disabled,
allow_transfer = :AllowTransfer
where r.id = :Id and r.domain_id = :Domain
returning *
)
select tmp.id, tmp.domain_id, tmp.name, tmp.description, tmp.created_at, call_center.cc_get_lookup(c.id, c.name) as created_by,
tmp.created_at, call_center.cc_get_lookup(u.id, u.name) as updated_by, tmp.updated_at, call_center.cc_get_lookup(arst.id, arst.name) as schema,
tmp.pattern, disabled
tmp.created_at, call_center.cc_get_lookup(u.id, u.name) as updated_by, tmp.updated_at, call_center.cc_get_lookup(arst.id, arst.name) as schema,
tmp.pattern, disabled, allow_transfer
from tmp
left join directory.wbt_user c on c.id = tmp.created_by
left join directory.wbt_user u on u.id = tmp.updated_by
inner join flow.acr_routing_scheme arst on tmp.scheme_id = arst.id`,
map[string]interface{}{
"Id": routing.Id,
"Domain": routing.DomainId,
"Name": routing.Name,
"Description": routing.Description,
"UpdatedAt": routing.UpdatedAt,
"UpdatedBy": routing.UpdatedBy.GetSafeId(),
"SchemeId": routing.Schema.Id,
"Pattern": routing.Pattern,
"Disabled": routing.Disabled,
"Id": routing.Id,
"Domain": routing.DomainId,
"Name": routing.Name,
"Description": routing.Description,
"UpdatedAt": routing.UpdatedAt,
"UpdatedBy": routing.UpdatedBy.GetSafeId(),
"SchemeId": routing.Schema.Id,
"Pattern": routing.Pattern,
"Disabled": routing.Disabled,
"AllowTransfer": routing.AllowTransfer,
})

if err != nil {
Expand Down
Loading
Loading