
// generateContent.go is used to generate fake messages, profiles, reviews, and reports.
// This is useful for simulating what use of Seekia is like, debugging, and building new features.

package main

import "seekia/internal/appUsers"
import "seekia/internal/localFilesystem"
import "seekia/internal/network/appNetworkType/getAppNetworkType"
import "seekia/internal/generate"

import "errors"
import "log"

func main(){

	generateContentFunction := func()error{

		err := localFilesystem.InitializeAppDatastores()
		if (err != nil){
			return errors.New("Failed to initialize app datastores: " + err.Error())
		}

		appUsersList, err := appUsers.GetAppUsersList()
		if (err != nil){
			return errors.New("Failed to GetAppUsersList: " + err.Error())
		}

		if (len(appUsersList) == 0){
			// We cannot generate fake content if there is no app user.
			return errors.New("No app users exist.")
		}

		// We always generate content for the first app user.
		appUserName := appUsersList[0]

		err = appUsers.SignInToAppUser(appUserName, false)
		if (err != nil){ return err }

		appNetworkType, err := getAppNetworkType.GetAppNetworkType()
		if (err != nil) { return err }
		
		err = generate.GenerateFakeProfiles("Mate", appNetworkType, 10)
		if (err != nil){ return err }

		//TODO: We will uncomment this once we can generate valid host profiles
		//err = generate.GenerateFakeProfiles("Host", 5)
		//if (err != nil){ return err }

		err = generate.GenerateFakeProfiles("Moderator", appNetworkType, 5)
		if (err != nil){ return err }

		err = generate.GenerateDisabledProfiles("Mate", appNetworkType, 3)
		if (err != nil){ return err }
		err = generate.GenerateDisabledProfiles("Host", appNetworkType, 3)
		if (err != nil){ return err }
		err = generate.GenerateDisabledProfiles("Moderator", appNetworkType, 3)
		if (err != nil){ return err }

		err = generate.GenerateFakeProfilesWithMessages("Mate", appNetworkType, 50)
		if (err != nil){ return err }

		err = generate.GenerateFakeReviews("Profile", appNetworkType, 30)
		if (err != nil){ return err }
		
		err = generate.GenerateFakeReviews("Identity", appNetworkType, 20)
		if (err != nil){ return err }
		err = generate.GenerateFakeReviews("Message", appNetworkType, 20)
		if (err != nil){ return err }		

		err = generate.GenerateFakeReports("Identity", appNetworkType, 20)
		if (err != nil){ return err }
		err = generate.GenerateFakeReports("Profile", appNetworkType, 20)
		if (err != nil){ return err }
		err = generate.GenerateFakeReports("Message", appNetworkType, 20)
		if (err != nil){ return err }

		err = appUsers.SignOutOfAppUser()
		if (err != nil){ return err }

		return nil
	}

	err := generateContentFunction()
	if (err != nil){
		log.Println("Failed to generate fake content. Error: " + err.Error())
		return
	}

	log.Println("Done generating fake content!")
}



