From da0746b9aa0ce4e3bc87af70d7c53849a978e770 Mon Sep 17 00:00:00 2001 From: TeoV Date: Fri, 15 Sep 2017 18:16:28 +0300 Subject: [PATCH] New check for TPid in apier/v2/tp.go --- apier/v2/tp.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apier/v2/tp.go b/apier/v2/tp.go index 2053fc17e..99afc3c4d 100644 --- a/apier/v2/tp.go +++ b/apier/v2/tp.go @@ -30,8 +30,8 @@ type AttrRemTp struct { } func (self *ApierV2) RemTP(attrs AttrRemTp, reply *string) error { - if len(attrs.TPid) == 0 { - return utils.NewErrMandatoryIeMissing("TPid") + if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { + return utils.NewErrMandatoryIeMissing(missing...) } if err := self.StorDb.RemTpData("", attrs.TPid, nil); err != nil { return utils.NewErrServerError(err) @@ -42,8 +42,8 @@ func (self *ApierV2) RemTP(attrs AttrRemTp, reply *string) error { } func (self *ApierV2) ExportTPToFolder(attrs utils.AttrDirExportTP, exported *utils.ExportedTPStats) error { - if len(*attrs.TPid) == 0 { - return utils.NewErrMandatoryIeMissing("TPid") + if missing := utils.MissingStructFields(&attrs, []string{"TPid", "ExportPath"}); len(missing) != 0 { + return utils.NewErrMandatoryIeMissing(missing...) } dir := self.Config.TpExportPath if attrs.ExportPath != nil { @@ -75,8 +75,8 @@ func (self *ApierV2) ExportTPToFolder(attrs utils.AttrDirExportTP, exported *uti } func (self *ApierV2) ExportTPToZipString(attrs utils.AttrDirExportTP, reply *string) error { - if len(*attrs.TPid) == 0 { - return utils.NewErrMandatoryIeMissing("TPid") + if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { + return utils.NewErrMandatoryIeMissing(missing...) } dir := "" fileFormat := utils.CSV