Skip to content

Commit 9fedda5

Browse files
committed
Merge branch 'master' of github.com:kiebitz-oss/services
2 parents 1fdcd6c + 004ba54 commit 9fedda5

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

servers/app_book_appointment.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ func (c *Appointments) bookAppointment(context *jsonrpc.Context, params *service
7474
return context.Error(400, "invalid signature", nil)
7575
}
7676

77+
// test if provider of the appointment is still active
78+
if res, isActive := c.isActiveProviderID(context, params.Data.ProviderID); res != nil {
79+
return res
80+
} else if !isActive {
81+
return context.Error(404, "invalid provider id", nil)
82+
}
83+
7784
appointmentsByID := c.db.Map("appointmentsByID", params.Data.ProviderID)
7885

7986
if date, err := appointmentsByID.Get(params.Data.ID); err != nil {

servers/appointments.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,19 @@ func (c *Appointments) isProvider(context *jsonrpc.Context, data, signature, pub
278278
return c.isOnKeyList(context, data, signature, publicKey, keys.Providers)
279279
}
280280

281+
func (c *Appointments) isActiveProviderID(context *jsonrpc.Context, publicKey []byte) (*jsonrpc.Response, bool) {
282+
activeProvider, err := c.db.Map("keys", []byte("providers")).Get([]byte(publicKey))
283+
284+
if len(activeProvider) == 0 {
285+
return context.Error(404, "provider not found", nil), false
286+
} else if err != nil {
287+
services.Log.Error(err)
288+
return context.InternalError(), false
289+
}
290+
291+
return nil, true
292+
}
293+
281294
func (c *Appointments) isOnKeyList(context *jsonrpc.Context, data, signature, publicKey []byte, keyList []*services.ActorKey) (*jsonrpc.Response, *services.ActorKey) {
282295

283296
actorKey, err := findActorKey(keyList, publicKey)

0 commit comments

Comments
 (0)