func RemoveMessageFromBox(w http.ResponseWriter, req *http.Request) {
	haddr, err := hash.NewFromHash(mux.Vars(req)["addr"])
	if err != nil {
		httputils.ErrorOut(w, http.StatusNotFound, accountNotFound)
		return
	}

	messageID := mux.Vars(req)["message"]

	var input moveMessageInput
	err = httputils.DecodeBody(w, req.Body, &input)
	if err != nil {
		httputils.ErrorOut(w, http.StatusBadRequest, err.Error())
		return
	}

	ar := container.Instance.GetAccountRepo()
	err = ar.RemoveFromBox(*haddr, input.From, messageID)
	if err != nil {
		httputils.ErrorOut(w, http.StatusNotFound, err.Error())
		return
	}

	// Should the message be removed if it's not linked to any mailbox?
	boxes, err := ar.GetAllBoxes(*haddr)
	if err == nil {
		var found bool
		for box := range boxes {
			if ar.ExistsInBox(*haddr, box, messageID) {
				found = true
			}
		}
		if !found {
			ar.RemoveMessage(*haddr, messageID)
		}
	}

	httputils.JSONOut(w, http.StatusOK, "")
}
// RemoveMessageFromBox will remove a message from a box
RemoveMessageFromBox will remove a message from a box
// RemoveMessageFromBox will remove a message from a box
func RemoveMessageFromBox(w http.ResponseWriter, req *http.Request) {
	haddr, err := hash.NewFromHash(mux.Vars(req)["addr"])
	if err != nil {
		httputils.ErrorOut(w, http.StatusNotFound, accountNotFound)
		return
	}
	messageID := mux.Vars(req)["message"]
	var input moveMessageInput
	err = httputils.DecodeBody(w, req.Body, &input)
	if err != nil {
		httputils.ErrorOut(w, http.StatusBadRequest, err.Error())
		return
	}
	ar := container.Instance.GetAccountRepo()
	err = ar.RemoveFromBox(*haddr, input.From, messageID)
	if err != nil {
		httputils.ErrorOut(w, http.StatusNotFound, err.Error())
		return
	}
	boxes, err := ar.GetAllBoxes(*haddr)
	if err == nil {
		var found bool
		for box := range boxes {
			if ar.ExistsInBox(*haddr, box, messageID) {
				found = true
			}
		}
		if !found {
			ar.RemoveMessage(*haddr, messageID)
		}
	}
	httputils.JSONOut(w, http.StatusOK, "")
}
func RemoveMessageFromBox ( w http . ResponseWriter , req * http . Request ) { haddr , err := hash . NewFromHash ( mux . Vars ( req ) [ " " ] ) if err != nil { httputils . ErrorOut ( w , http . StatusNotFound , accountNotFound ) return } messageID := mux . Vars ( req ) [ " " ] var input moveMessageInput err = httputils . DecodeBody ( w , req . Body , & input ) if err != nil { httputils . ErrorOut ( w , http . StatusBadRequest , err . Error ( ) ) return } ar := container . Instance . GetAccountRepo ( ) err = ar . RemoveFromBox ( * haddr , input . From , messageID ) if err != nil { httputils . ErrorOut ( w , http . StatusNotFound , err . Error ( ) ) return } boxes , err := ar . GetAllBoxes ( * haddr ) if err == nil { var found bool for box := range boxes { if ar . ExistsInBox ( * haddr , box , messageID ) { found = true } } if ! found { ar . RemoveMessage ( * haddr , messageID ) } } httputils . JSONOut ( w , http . StatusOK , " " ) }
RemoveMessageFromBox will remove a message from a box
RemoveMessageFromBox will remove a message from a box
// Should the message be removed if it's not linked to any mailbox?