func UpdateWarningSent(entity *models.Warning, db gorp.SqlExecutor) bool { entity.Sent = true entity.Last_modified_date = time.Now().String() _, err := db.Update(entity) checkErr(err, "ERROR UpdateWarningSent ERROR") return err == nil }
// Receives a warning tru, inserts the request and process the warning and then respond to the interface //TODO: use (session sessions.Session, r *http.Request) to prevent flood func AddWarning(entity models.Warning, enc Encoder, db gorp.SqlExecutor, r *http.Request) (int, string) { fmt.Println("AddWarning") if isInvalidWarning(&entity) { return http.StatusBadRequest, Must(enc.EncodeOne(entity)) } status := &models.DefaultStruct{ Id: http.StatusOK, Name: messages.GetLocaleMessage(entity.Lang_key, "MSG_WARNING_SENT_SUCCESS"), Lang_key: entity.Lang_key, Type: models.MSG_TYPE_WARNING, } entity.Sent = false entity.Created_by = "system" //entity.Created_date = time.Now().String() err := db.Insert(&entity) checkErr(err, "INSERT WARNING ERROR") if err != nil { return http.StatusBadRequest, Must(enc.EncodeOne(entity)) } ingnored := InIgnoreList(db, entity.Contact) if ingnored != nil && ingnored.Confirmed { status = &models.DefaultStruct{ Id: http.StatusBadRequest, Name: messages.GetLocaleMessage(entity.Lang_key, "MSG_IGNORED_USER"), Lang_key: entity.Lang_key, Type: models.MSG_TYPE_WARNING, } } else { processWarn(&entity, db, status) } return http.StatusCreated, Must(enc.EncodeOne(status)) }