func (VS *Server) addMessage(c *gin.Context) {
	idConver, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	user := VS.getUserFomCookie(c, "h_comunication", "addMessage", "user := VS.getUserFomCookie")
	// We leave open the possibility that there is no audio or photo/video
	photo, audio := "", ""
	p, _ := c.FormFile("photo")
	a, _ := c.FormFile("audio")
	id := bson.NewObjectId()
	if p != nil {
		photo, b = VS.getFileFromHTML(c, "photo", id.Hex(), basePath+"/local-resources/conversations/"+idConver.Hex()+"/")
		if !b {
			return
		}
	}
	if a != nil {
		audio, b = VS.getFileFromHTML(c, "audio", id.Hex(), basePath+"/local-resources/conversations/"+idConver.Hex()+"/")
		if !b {
			return
		}
	}
	text, _ := VS.getStringFromHTML(c, "message", "Message")
	msg := Message{
		ID:             id,
		IDUser:         user.ID,
		IDConversation: idConver,
		Text:           text,
		Photo:          photo,
		Audio:          audio,
		Date:           getTime(),
	}
	VS.addElementToDatabaseWithRegisterFromCentral(c, msg, msg.ID, "h_comunication", "addMessage", "VS.addElementToDatabaseWithRegisterFromCentral")
	c.Redirect(http.StatusFound, "/comunication/chat/"+idConver.Hex())
}
// This handler adds the message to the conversation
This handler adds the message to the conversation
// This handler adds the message to the conversation
func (VS *Server) addMessage(c *gin.Context) {
	idConver, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	user := VS.getUserFomCookie(c, "h_comunication", "addMessage", "user := VS.getUserFomCookie")
	photo, audio := "", ""
	p, _ := c.FormFile("photo")
	a, _ := c.FormFile("audio")
	id := bson.NewObjectId()
	if p != nil {
		photo, b = VS.getFileFromHTML(c, "photo", id.Hex(), basePath+"/local-resources/conversations/"+idConver.Hex()+"/")
		if !b {
			return
		}
	}
	if a != nil {
		audio, b = VS.getFileFromHTML(c, "audio", id.Hex(), basePath+"/local-resources/conversations/"+idConver.Hex()+"/")
		if !b {
			return
		}
	}
	text, _ := VS.getStringFromHTML(c, "message", "Message")
	msg := Message{
		ID:             id,
		IDUser:         user.ID,
		IDConversation: idConver,
		Text:           text,
		Photo:          photo,
		Audio:          audio,
		Date:           getTime(),
	}
	VS.addElementToDatabaseWithRegisterFromCentral(c, msg, msg.ID, "h_comunication", "addMessage", "VS.addElementToDatabaseWithRegisterFromCentral")
	c.Redirect(http.StatusFound, "/comunication/chat/"+idConver.Hex())
}
func ( VS * Server ) addMessage ( c * gin . Context ) { idConver , b := VS . getIDParamFromURL ( c , " " ) if ! b { return } user := VS . getUserFomCookie ( c , " " , " " , " " ) photo , audio := " " , " " p , _ := c . FormFile ( " " ) a , _ := c . FormFile ( " " ) id := bson . NewObjectId ( ) if p != nil { photo , b = VS . getFileFromHTML ( c , " " , id . Hex ( ) , basePath + " " + idConver . Hex ( ) + " " ) if ! b { return } } if a != nil { audio , b = VS . getFileFromHTML ( c , " " , id . Hex ( ) , basePath + " " + idConver . Hex ( ) + " " ) if ! b { return } } text , _ := VS . getStringFromHTML ( c , " " , " " ) msg := Message { ID : id , IDUser : user . ID , IDConversation : idConver , Text : text , Photo : photo , Audio : audio , Date : getTime ( ) , } VS . addElementToDatabaseWithRegisterFromCentral ( c , msg , msg . ID , " " , " " , " " ) c . Redirect ( http . StatusFound , " " + idConver . Hex ( ) ) }
This handler adds the message to the conversation
This handler adds the message to the conversation
// We leave open the possibility that there is no audio or photo/video