
// readContent provides a function to verify a piece of content
// "Content" refers to a Profile, Message, Review, Report, or Parameters

package readContent

import "seekia/internal/profiles/readProfiles"
import "seekia/internal/messaging/readMessages"
import "seekia/internal/moderation/readReviews"
import "seekia/internal/moderation/readReports"
import "seekia/internal/parameters/readParameters"

import "errors"

//Outputs:
//	-bool: Able to read content
//	-[]byte: Content Hash
//	-error
func GetContentHashFromContentBytes(verifyContent bool, contentType string, contentBytes []byte)(bool, []byte, error){

	if (contentType == "Profile"){

		ableToRead, profileHash, _, _, _, _, _, _, err := readProfiles.ReadProfileAndHash(verifyContent, contentBytes)
		if (err != nil) { return false, nil, err }
		if (ableToRead == false){
			return false, nil, nil
		}
		return true, profileHash[:], nil
	}
	if (contentType == "Message"){

		ableToRead, messageHash, _, _, _, _, _, _, _, _, _, err := readMessages.ReadChatMessagePublicDataAndHash(verifyContent, contentBytes)
		if (err != nil){ return false, nil, err }
		if (ableToRead == false){
			return false, nil, nil
		}

		return true, messageHash[:], nil
	}
	if (contentType == "Review"){

		ableToRead, reviewHash, _, _, _, _, _, _, _, _, err := readReviews.ReadReviewAndHash(verifyContent, contentBytes)
		if (err != nil) { return false, nil, err }
		if (ableToRead == false){
			return false, nil, nil
		}

		return true, reviewHash[:], nil
	}
	if (contentType == "Report"){

		ableToRead, reportHash, _, _, _, _, _, _, err := readReports.ReadReportAndHash(verifyContent, contentBytes)
		if (err != nil){ return false, nil, err }
		if (ableToRead == false){
			return false, nil, nil
		}

		return true, reportHash[:], nil
	}

	if (contentType == "Parameters"){

		ableToRead, parametersHash, _, _, _, _, _, _, err := readParameters.ReadParametersAndHash(verifyContent, contentBytes)
		if (err != nil){ return false, nil, err }
		if (ableToRead == false){
			return false, nil, nil
		}

		return true, parametersHash[:], nil
	}

	return false, nil, errors.New("GetContentHashFromContentBytes called with invalid contentType: " + contentType)
}





