api/event.go
func eventBlockAdd(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	if !permission.Check(t, permission.PermEventBlockAdd) {
		return permission.ErrUnauthorized
	}
	var block event.Block
	err = ParseInput(r, &block)
	if err != nil {
		return err
	}
	if block.Reason == "" {
		return &errors.HTTP{Code: http.StatusBadRequest, Message: "reason is required"}
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeEventBlock},
		Kind:       permission.PermEventBlockAdd,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermEventBlockReadEvents),
	})
	if err != nil {
		return err
	}
	defer func() {
		evt.Target.Value = block.ID.Hex()
		evt.Done(err)
	}()
	return event.AddBlock(&block)
}
func eventBlockAdd(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	if !permission.Check(t, permission.PermEventBlockAdd) {
		return permission.ErrUnauthorized
	}
	var block event.Block
	err = ParseInput(r, &block)
	if err != nil {
		return err
	}
	if block.Reason == "" {
		return &errors.HTTP{Code: http.StatusBadRequest, Message: "reason is required"}
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeEventBlock},
		Kind:       permission.PermEventBlockAdd,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermEventBlockReadEvents),
	})
	if err != nil {
		return err
	}
	defer func() {
		evt.Target.Value = block.ID.Hex()
		evt.Done(err)
	}()
	return event.AddBlock(&block)
}
// title: add event block
// path: /events/blocks
// method: POST
// consume: application/x-www-form-urlencoded
// responses:
//   200: OK
//   400: Invalid data or empty reason
//   401: Unauthorized