Documentation ¶
Overview ¶
Package services implements services, mainly the repository.
Index ¶
- type Email
- type EmailService
- type Files
- func (f *Files) BackupGlobal() error
- func (f *Files) BackupUserData(repo RepositoryService, userID int64) error
- func (f *Files) BackupUsersData(repo RepositoryService) error
- func (f *Files) Backups(userID int64) []time.Time
- func (f *Files) ExportCookbook(cookbook models.Cookbook, fileType models.FileType) (string, error)
- func (f *Files) ExportRecipes(recipes models.Recipes, fileType models.FileType, progress chan int) (*bytes.Buffer, error)
- func (f *Files) ExtractRecipes(fileHeaders []*multipart.FileHeader) models.Recipes
- func (f *Files) ExtractUserBackup(date string, userID int64) (*models.UserBackup, error)
- func (f *Files) IsAppLatest(current semver.Version) (bool, *github.RepositoryRelease, error)
- func (f *Files) ReadTempFile(name string) ([]byte, error)
- func (f *Files) ScrapeAndStoreImage(rawURL string) (uuid.UUID, error)
- func (f *Files) UpdateApp(current semver.Version) error
- func (f *Files) UploadImage(rc io.ReadCloser) (uuid.UUID, error)
- type FilesService
- type Integrations
- type IntegrationsService
- type RepositoryService
- type SQLiteService
- func (s *SQLiteService) AddAuthToken(selector, validator string, userID int64) error
- func (s *SQLiteService) AddCookbook(title string, userID int64) (int64, error)
- func (s *SQLiteService) AddCookbookRecipe(cookbookID, recipeID, userID int64) error
- func (s *SQLiteService) AddRecipe(r *models.Recipe, userID int64, settings models.UserSettings) (int64, error)
- func (s *SQLiteService) AddRecipeTx(ctx context.Context, tx *sql.Tx, r *models.Recipe, userID int64) (int64, error)
- func (s *SQLiteService) AddReport(report models.Report, userID int64)
- func (s *SQLiteService) AddShareLink(share models.Share) (string, error)
- func (s *SQLiteService) AppInfo() (models.AppInfo, error)
- func (s *SQLiteService) CalculateNutrition(userID int64, recipes []int64, settings models.UserSettings)
- func (s *SQLiteService) Categories(userID int64) ([]string, error)
- func (s *SQLiteService) CheckUpdate(files FilesService) (models.AppInfo, error)
- func (s *SQLiteService) Confirm(userID int64) error
- func (s *SQLiteService) Cookbook(id, userID int64) (models.Cookbook, error)
- func (s *SQLiteService) CookbookByID(id, userID int64) (models.Cookbook, error)
- func (s *SQLiteService) CookbookRecipe(id, cookbookID int64) (recipe *models.Recipe, userID int64, err error)
- func (s *SQLiteService) CookbookShared(link string) (*models.Share, error)
- func (s *SQLiteService) Cookbooks(userID int64, page uint64) ([]models.Cookbook, error)
- func (s *SQLiteService) CookbooksShared(userID int64) ([]models.Share, error)
- func (s *SQLiteService) CookbooksUser(userID int64) ([]models.Cookbook, error)
- func (s *SQLiteService) Counts(userID int64) (models.Counts, error)
- func (s *SQLiteService) DeleteAuthToken(userID int64) error
- func (s *SQLiteService) DeleteCookbook(id, userID int64) error
- func (s *SQLiteService) DeleteRecipe(id, userID int64) error
- func (s *SQLiteService) DeleteRecipeFromCookbook(recipeID, cookbookID int64, userID int64) (int64, error)
- func (s *SQLiteService) DeleteUser(id int64) error
- func (s *SQLiteService) GetAuthToken(selector, validator string) (models.AuthToken, error)
- func (s *SQLiteService) Images() []string
- func (s *SQLiteService) InitAutologin() error
- func (s *SQLiteService) IsUserExist(email string) bool
- func (s *SQLiteService) IsUserPassword(id int64, password string) bool
- func (s *SQLiteService) MeasurementSystems(userID int64) ([]units.System, models.UserSettings, error)
- func (s *SQLiteService) Nutrients(ingredients []string) (models.NutrientsFDC, float64, error)
- func (s *SQLiteService) Recipe(id, userID int64) (*models.Recipe, error)
- func (s *SQLiteService) RecipeShared(link string) (*models.Share, error)
- func (s *SQLiteService) RecipeUser(recipeID int64) int64
- func (s *SQLiteService) Recipes(userID int64, page uint64, sorts string) models.Recipes
- func (s *SQLiteService) RecipesAll(userID int64) models.Recipes
- func (s *SQLiteService) RecipesShared(userID int64) ([]models.Share, error)
- func (s *SQLiteService) Register(email string, hashedPassword auth.HashedPassword) (int64, error)
- func (s *SQLiteService) ReorderCookbookRecipes(cookbookID int64, recipeIDs []uint64, userID int64) error
- func (s *SQLiteService) Report(id, userID int64) ([]models.ReportLog, error)
- func (s *SQLiteService) ReportsImport(userID int64) ([]models.Report, error)
- func (s *SQLiteService) RestoreUserBackup(backup *models.UserBackup) error
- func (s *SQLiteService) SearchRecipes(query string, page uint64, options models.SearchOptionsRecipes, userID int64) (models.Recipes, uint64, error)
- func (s *SQLiteService) SwitchMeasurementSystem(system units.System, userID int64) error
- func (s *SQLiteService) UpdateCalculateNutrition(userID int64, isEnabled bool) error
- func (s *SQLiteService) UpdateConvertMeasurementSystem(userID int64, isEnabled bool) error
- func (s *SQLiteService) UpdateCookbookImage(id int64, image uuid.UUID, userID int64) error
- func (s *SQLiteService) UpdatePassword(userID int64, password auth.HashedPassword) error
- func (s *SQLiteService) UpdateRecipe(updatedRecipe *models.Recipe, userID int64, recipeNum int64) error
- func (s *SQLiteService) UpdateUserSettingsCookbooksViewMode(userID int64, mode models.ViewMode) error
- func (s *SQLiteService) UserID(email string) int64
- func (s *SQLiteService) UserInitials(userID int64) string
- func (s *SQLiteService) UserSettings(userID int64) (models.UserSettings, error)
- func (s *SQLiteService) Users() []models.User
- func (s *SQLiteService) VerifyLogin(email, password string) int64
- func (s *SQLiteService) Websites() models.Websites
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email is the entity that manages the email client.
func (*Email) Queue ¶
func (e *Email) Queue(to string, template templates.EmailTemplate, data any)
Queue adds an unsent email to the queue.
func (*Email) RateLimits ¶
RateLimits gets the SendGrid API's remaining and reset rate limits.
type EmailService ¶
type EmailService interface { // Queue adds an unsent email to the queue. Queue(to string, template templates.EmailTemplate, data any) // RateLimits gets the SendGrid API's remaining and reset rate limits. RateLimits() (remaining int, resetUnix int64, err error) // Send sends an email using the SendGrid API. Send(to string, template templates.EmailTemplate, data any) error // SendQueue sends emails in the queue until the rate limit has been reached. SendQueue() (sent, remaining int, err error) }
EmailService is the interface that describes the methods required for the email client.
type Files ¶
type Files struct{}
Files is the entity that manages the email client.
func NewFilesService ¶
func NewFilesService() *Files
NewFilesService creates a new Files that satisfies the FilesService interface.
func (*Files) BackupGlobal ¶ added in v1.1.0
BackupGlobal backs up the whole database to the backup directory.
func (*Files) BackupUserData ¶ added in v1.1.0
func (f *Files) BackupUserData(repo RepositoryService, userID int64) error
BackupUserData backs up a specific user's data to the backup directory.
func (*Files) BackupUsersData ¶ added in v1.1.0
func (f *Files) BackupUsersData(repo RepositoryService) error
BackupUsersData backs up each user's data to the backup directory.
func (*Files) Backups ¶ added in v1.1.0
Backups gets the list of backup dates sorted in descending order for the given user.
func (*Files) ExportCookbook ¶
ExportCookbook exports the cookbook in the desired file type. It returns the name of file in the temporary directory.
func (*Files) ExportRecipes ¶
func (f *Files) ExportRecipes(recipes models.Recipes, fileType models.FileType, progress chan int) (*bytes.Buffer, error)
ExportRecipes creates a zip containing the recipes to export in the desired file type.
func (*Files) ExtractRecipes ¶
func (f *Files) ExtractRecipes(fileHeaders []*multipart.FileHeader) models.Recipes
ExtractRecipes extracts the recipes from the HTTP files.
func (*Files) ExtractUserBackup ¶ added in v1.1.0
ExtractUserBackup extracts data from the user backup for restoration.
func (*Files) IsAppLatest ¶ added in v1.1.0
IsAppLatest checks whether there is a software update.
func (*Files) ReadTempFile ¶
ReadTempFile gets the content of a file in the temporary directory.
func (*Files) ScrapeAndStoreImage ¶ added in v1.1.0
ScrapeAndStoreImage takes a URL as input and will download and store the image, and return a UUID referencing the image's internal ID
func (*Files) UploadImage ¶
UploadImage uploads an image to the server.
type FilesService ¶
type FilesService interface { // BackupGlobal backs up the whole database to the backup directory. BackupGlobal() error // Backups gets the list of backup dates sorted in descending order for the given user. Backups(userID int64) []time.Time // BackupUserData backs up a specific user's data to the backup directory. BackupUserData(repo RepositoryService, userID int64) error // BackupUsersData backs up each user's data to the backup directory. BackupUsersData(repo RepositoryService) error // ExportCookbook exports the cookbook in the desired file type. // It returns the name of file in the temporary directory. ExportCookbook(cookbook models.Cookbook, fileType models.FileType) (string, error) // ExportRecipes creates a zip containing the recipes to export in the desired file type. ExportRecipes(recipes models.Recipes, fileType models.FileType, progress chan int) (*bytes.Buffer, error) // ExtractRecipes extracts the recipes from the HTTP files. ExtractRecipes(fileHeaders []*multipart.FileHeader) models.Recipes // ExtractUserBackup extracts data from the user backup for restoration. ExtractUserBackup(date string, userID int64) (*models.UserBackup, error) // IsAppLatest checks whether there is a software update. IsAppLatest(current semver.Version) (bool, *github.RepositoryRelease, error) // ReadTempFile gets the content of a file in the temporary directory. ReadTempFile(name string) ([]byte, error) // ScrapeAndStoreImage takes a URL as input and will download and store the image, and return a UUID referencing the image's internal ID ScrapeAndStoreImage(rawURL string) (uuid.UUID, error) // UpdateApp updates the application to the latest version. UpdateApp(current semver.Version) error // UploadImage uploads an image to the server. UploadImage(rc io.ReadCloser) (uuid.UUID, error) }
FilesService is the interface that describes the methods required for manipulating files.
type Integrations ¶
type Integrations struct{}
Integrations is the entity that manages software integrations.
func NewIntegrationsService ¶
func NewIntegrationsService() *Integrations
NewIntegrationsService creates a new Integrations that satisfies the IntegrationsService interface.
func (*Integrations) NextcloudImport ¶
func (i *Integrations) NextcloudImport(baseURL, username, password string, files FilesService, progress chan models.Progress) (*models.Recipes, error)
NextcloudImport imports the recipes from a Nextcloud instance.
func (*Integrations) ProcessImageOCR ¶
ProcessImageOCR processes an image using an OCR service to extract the recipe.
type IntegrationsService ¶
type IntegrationsService interface { // NextcloudImport imports the recipes from a Nextcloud instance. NextcloudImport(baseURL, username, password string, files FilesService, progress chan models.Progress) (*models.Recipes, error) // ProcessImageOCR processes an image using an OCR service to extract the recipe. ProcessImageOCR(file io.Reader) (models.Recipe, error) }
IntegrationsService is the interface that describes the methods required for various software integrations.
type RepositoryService ¶
type RepositoryService interface { // AddAuthToken adds an authentication token to the database. AddAuthToken(selector, validator string, userID int64) error // AddCookbook adds a cookbook to the database. AddCookbook(title string, userID int64) (int64, error) // AddCookbookRecipe adds a recipe to the cookbook. AddCookbookRecipe(cookbookID, recipeID, userID int64) error // AddRecipe adds a recipe to the user's collection. AddRecipe(r *models.Recipe, userID int64, settings models.UserSettings) (int64, error) // AddRecipeTx adds a recipe to the user's collection using an existing database transaction. AddRecipeTx(ctx context.Context, tx *sql.Tx, r *models.Recipe, userID int64) (int64, error) // AddReport adds a report to the database. AddReport(report models.Report, userID int64) AddShareLink(share models.Share) (string, error) // CalculateNutrition calculates the nutrition facts for the recipes. // It is best to in the background because it takes a while per recipe. CalculateNutrition(userID int64, recipes []int64, settings models.UserSettings) // Categories gets all categories in the database. Categories(userID int64) ([]string, error) // CheckUpdate checks whether there is a new release for Recipya. // It returns the latest information on the application. CheckUpdate(files FilesService) (models.AppInfo, error) // Confirm confirms the user's account. Confirm(userID int64) error // Cookbook gets a cookbook by its ID. Cookbook(id, userID int64) (models.Cookbook, error) // CookbookRecipe gets a recipe from a cookbook. CookbookRecipe(id, cookbookID int64) (recipe *models.Recipe, userID int64, err error) // It returns a models.Share. Otherwise, an error. CookbookShared(id string) (*models.Share, error) // Cookbooks gets a limited number of cookbooks belonging to the user. Cookbooks(userID int64, page uint64) ([]models.Cookbook, error) CookbooksShared(userID int64) ([]models.Share, error) // CookbooksUser gets all the user's cookbooks. CookbooksUser(userID int64) ([]models.Cookbook, error) // Counts gets the models.Counts for the user. Counts(userID int64) (models.Counts, error) // DeleteAuthToken removes an authentication token from the database. DeleteAuthToken(userID int64) error // DeleteCookbook deletes a user's cookbook. DeleteCookbook(id, userID int64) error // DeleteRecipe deletes a user's recipe. DeleteRecipe(id, userID int64) error // DeleteRecipeFromCookbook deletes a recipe from a cookbook. It returns the number of recipes in the cookbook. DeleteRecipeFromCookbook(recipeID, cookbookID int64, userID int64) (int64, error) // DeleteUser deletes a user and his or her data. DeleteUser(id int64) error // GetAuthToken gets a non-expired auth token by the selector. GetAuthToken(selector, validator string) (models.AuthToken, error) // Images fetches all distinct image UUIDs for recipes. // An empty slice is returned when an error occurred. Images() []string // InitAutologin creates a default user for the autologin feature if no users are present. InitAutologin() error // IsUserExist checks whether the user is present in the database. IsUserExist(email string) bool // IsUserPassword checks whether the password is the user's password. IsUserPassword(id int64, password string) bool // MeasurementSystems gets the units systems, along with the one the user selected, in the database. MeasurementSystems(userID int64) ([]units.System, models.UserSettings, error) // Nutrients gets the nutrients for the ingredients from the FDC database, along with the total weight. Nutrients(ingredients []string) (models.NutrientsFDC, float64, error) // Recipe gets the user's recipe of the given id. Recipe(id, userID int64) (*models.Recipe, error) // Recipes gets the user's recipes. Recipes(userID int64, page uint64, sorts string) models.Recipes // RecipesAll gets all the user's recipes. RecipesAll(userID int64) models.Recipes // It returns a models.Share. Otherwise, an error. RecipeShared(id string) (*models.Share, error) RecipesShared(userID int64) ([]models.Share, error) // RecipeUser gets the user for which the recipe belongs to. RecipeUser(recipeID int64) int64 // Register adds a new user to the store. Register(email string, hashPassword auth.HashedPassword) (int64, error) // ReorderCookbookRecipes reorders the recipe indices of a cookbook. ReorderCookbookRecipes(cookbookID int64, recipeIDs []uint64, userID int64) error // Report gets a report of any type belonging to the user. Report(id, userID int64) ([]models.ReportLog, error) // ReportsImport gets all import reports. ReportsImport(userID int64) ([]models.Report, error) // RestoreUserBackup restores the user's data. RestoreUserBackup(backup *models.UserBackup) error // SearchRecipes searches for recipes based on the configuration. // It returns the paginated search recipes, the total number of search results and an error. SearchRecipes(query string, page uint64, options models.SearchOptionsRecipes, userID int64) (models.Recipes, uint64, error) // SwitchMeasurementSystem sets the user's units system to the desired one. SwitchMeasurementSystem(system units.System, userID int64) error // UpdateCalculateNutrition updates the user's calculate nutrition facts automatically setting. UpdateCalculateNutrition(userID int64, isEnabled bool) error // UpdateConvertMeasurementSystem updates the user's convert automatically setting. UpdateConvertMeasurementSystem(userID int64, isEnabled bool) error // UpdateCookbookImage updates the image of a user's cookbook. UpdateCookbookImage(id int64, image uuid.UUID, userID int64) error // UpdatePassword updates the user's password. UpdatePassword(userID int64, hashedPassword auth.HashedPassword) error // UpdateRecipe updates the recipe with its new values. UpdateRecipe(updatedRecipe *models.Recipe, userID int64, recipeNum int64) error // UpdateUserSettingsCookbooksViewMode updates the user's preferred cookbooks viewing mode. UpdateUserSettingsCookbooksViewMode(userID int64, mode models.ViewMode) error // UserID gets the user's id from the email. It returns -1 if user not found. UserID(email string) int64 // UserSettings gets the user's settings. UserSettings(userID int64) (models.UserSettings, error) // UserInitials gets the user's initials of maximum two characters. UserInitials(userID int64) string // Users gets all users in the database. Users() []models.User // VerifyLogin checks whether the user provided correct login credentials. // If yes, their user ID will be returned. Otherwise, -1 is returned. VerifyLogin(email, password string) int64 // Websites gets the list of supported websites from which to extract the recipe. Websites() models.Websites }
RepositoryService is the interface that describes the methods required for managing the main data store.
type SQLiteService ¶
SQLiteService represents the Service implemented with SQLite.
func NewSQLiteService ¶
func NewSQLiteService() *SQLiteService
NewSQLiteService creates an SQLiteService object.
func (*SQLiteService) AddAuthToken ¶
func (s *SQLiteService) AddAuthToken(selector, validator string, userID int64) error
AddAuthToken adds an authentication token to the database.
func (*SQLiteService) AddCookbook ¶
func (s *SQLiteService) AddCookbook(title string, userID int64) (int64, error)
AddCookbook adds a cookbook to the database.
func (*SQLiteService) AddCookbookRecipe ¶
func (s *SQLiteService) AddCookbookRecipe(cookbookID, recipeID, userID int64) error
AddCookbookRecipe adds a recipe to the cookbook.
func (*SQLiteService) AddRecipe ¶
func (s *SQLiteService) AddRecipe(r *models.Recipe, userID int64, settings models.UserSettings) (int64, error)
AddRecipe adds a recipe to the user's collection.
func (*SQLiteService) AddRecipeTx ¶ added in v1.1.0
func (s *SQLiteService) AddRecipeTx(ctx context.Context, tx *sql.Tx, r *models.Recipe, userID int64) (int64, error)
AddRecipeTx adds a recipe to the user's collection using an existing database transaction.
func (*SQLiteService) AddReport ¶ added in v1.1.0
func (s *SQLiteService) AddReport(report models.Report, userID int64)
AddReport adds a report to the database.
func (*SQLiteService) AddShareLink ¶
func (s *SQLiteService) AddShareLink(share models.Share) (string, error)
AddShareLink adds a share link for the recipe.
func (*SQLiteService) AppInfo ¶ added in v1.1.0
func (s *SQLiteService) AppInfo() (models.AppInfo, error)
AppInfo gets general information on the application.
func (*SQLiteService) CalculateNutrition ¶
func (s *SQLiteService) CalculateNutrition(userID int64, recipes []int64, settings models.UserSettings)
CalculateNutrition calculates the nutrition facts for the recipes. It is best to in the background because it takes a while per recipe.
func (*SQLiteService) Categories ¶
func (s *SQLiteService) Categories(userID int64) ([]string, error)
Categories gets all categories in the database.
func (*SQLiteService) CheckUpdate ¶ added in v1.1.0
func (s *SQLiteService) CheckUpdate(files FilesService) (models.AppInfo, error)
CheckUpdate checks whether there is a new release for Recipya.
func (*SQLiteService) Confirm ¶
func (s *SQLiteService) Confirm(userID int64) error
Confirm confirms the user's account.
func (*SQLiteService) Cookbook ¶
func (s *SQLiteService) Cookbook(id, userID int64) (models.Cookbook, error)
Cookbook gets a cookbook belonging to a user.
func (*SQLiteService) CookbookByID ¶
func (s *SQLiteService) CookbookByID(id, userID int64) (models.Cookbook, error)
CookbookByID gets a cookbook by its ID.
func (*SQLiteService) CookbookRecipe ¶
func (s *SQLiteService) CookbookRecipe(id, cookbookID int64) (recipe *models.Recipe, userID int64, err error)
CookbookRecipe gets a recipe from a cookbook.
func (*SQLiteService) CookbookShared ¶
func (s *SQLiteService) CookbookShared(link string) (*models.Share, error)
CookbookShared checks whether the cookbook is shared. It returns a models.Share. Otherwise, an error.
func (*SQLiteService) Cookbooks ¶
Cookbooks gets a limited number of cookbooks belonging to the user.
func (*SQLiteService) CookbooksShared ¶ added in v1.1.0
func (s *SQLiteService) CookbooksShared(userID int64) ([]models.Share, error)
CookbooksShared gets the user's shared cookbooks.
func (*SQLiteService) CookbooksUser ¶ added in v1.1.0
func (s *SQLiteService) CookbooksUser(userID int64) ([]models.Cookbook, error)
CookbooksUser gets all the user's cookbooks.
func (*SQLiteService) Counts ¶
func (s *SQLiteService) Counts(userID int64) (models.Counts, error)
Counts gets the models.Counts for the user.
func (*SQLiteService) DeleteAuthToken ¶
func (s *SQLiteService) DeleteAuthToken(userID int64) error
DeleteAuthToken removes an authentication token from the database.
func (*SQLiteService) DeleteCookbook ¶
func (s *SQLiteService) DeleteCookbook(id, userID int64) error
DeleteCookbook deletes a user's cookbook.
func (*SQLiteService) DeleteRecipe ¶
func (s *SQLiteService) DeleteRecipe(id, userID int64) error
DeleteRecipe deletes a user's recipe. It returns the number of rows affected.
func (*SQLiteService) DeleteRecipeFromCookbook ¶
func (s *SQLiteService) DeleteRecipeFromCookbook(recipeID, cookbookID int64, userID int64) (int64, error)
DeleteRecipeFromCookbook deletes a recipe from a cookbook. It returns the number of recipes in the cookbook.
func (*SQLiteService) DeleteUser ¶
func (s *SQLiteService) DeleteUser(id int64) error
DeleteUser deletes a user and his or her data.
func (*SQLiteService) GetAuthToken ¶
func (s *SQLiteService) GetAuthToken(selector, validator string) (models.AuthToken, error)
GetAuthToken gets a non-expired auth token by the selector.
func (*SQLiteService) Images ¶
func (s *SQLiteService) Images() []string
Images fetches all distinct image UUIDs for recipes. An empty slice is returned when an error occurred.
func (*SQLiteService) InitAutologin ¶ added in v1.1.0
func (s *SQLiteService) InitAutologin() error
InitAutologin creates a default user for the autologin feature if no users are present.
func (*SQLiteService) IsUserExist ¶
func (s *SQLiteService) IsUserExist(email string) bool
IsUserExist checks whether the user is present in the database.
func (*SQLiteService) IsUserPassword ¶
func (s *SQLiteService) IsUserPassword(id int64, password string) bool
IsUserPassword checks whether the password is the user's password.
func (*SQLiteService) MeasurementSystems ¶
func (s *SQLiteService) MeasurementSystems(userID int64) ([]units.System, models.UserSettings, error)
MeasurementSystems gets the units systems, along with the one the user selected, in the database.
func (*SQLiteService) Nutrients ¶
func (s *SQLiteService) Nutrients(ingredients []string) (models.NutrientsFDC, float64, error)
Nutrients gets the nutrients for the ingredients from the FDC database, along with the total weight.
func (*SQLiteService) Recipe ¶
func (s *SQLiteService) Recipe(id, userID int64) (*models.Recipe, error)
Recipe gets the user's recipe of the given id.
func (*SQLiteService) RecipeShared ¶
func (s *SQLiteService) RecipeShared(link string) (*models.Share, error)
RecipeShared checks whether the recipe is shared. It returns a models.Share. Otherwise, an error.
func (*SQLiteService) RecipeUser ¶
func (s *SQLiteService) RecipeUser(recipeID int64) int64
RecipeUser gets the user for which the recipe belongs to.
func (*SQLiteService) RecipesAll ¶
func (s *SQLiteService) RecipesAll(userID int64) models.Recipes
RecipesAll gets all the user's recipes.
func (*SQLiteService) RecipesShared ¶ added in v1.1.0
func (s *SQLiteService) RecipesShared(userID int64) ([]models.Share, error)
RecipesShared gets all the user's shared recipes.
func (*SQLiteService) Register ¶
func (s *SQLiteService) Register(email string, hashedPassword auth.HashedPassword) (int64, error)
Register adds a new user to the store.
func (*SQLiteService) ReorderCookbookRecipes ¶
func (s *SQLiteService) ReorderCookbookRecipes(cookbookID int64, recipeIDs []uint64, userID int64) error
ReorderCookbookRecipes reorders the recipe indices of a cookbook.
func (*SQLiteService) Report ¶ added in v1.1.0
func (s *SQLiteService) Report(id, userID int64) ([]models.ReportLog, error)
Report gets a report of any type belonging to the user.
func (*SQLiteService) ReportsImport ¶ added in v1.1.0
func (s *SQLiteService) ReportsImport(userID int64) ([]models.Report, error)
ReportsImport gets all import reports.
func (*SQLiteService) RestoreUserBackup ¶ added in v1.1.0
func (s *SQLiteService) RestoreUserBackup(backup *models.UserBackup) error
RestoreUserBackup restores the user's data at the specified date.
func (*SQLiteService) SearchRecipes ¶
func (s *SQLiteService) SearchRecipes(query string, page uint64, options models.SearchOptionsRecipes, userID int64) (models.Recipes, uint64, error)
SearchRecipes searches for recipes based on the configuration. It returns the paginated search recipes, the total number of search results and an error.
func (*SQLiteService) SwitchMeasurementSystem ¶
func (s *SQLiteService) SwitchMeasurementSystem(system units.System, userID int64) error
SwitchMeasurementSystem sets the user's units system to the desired one.
func (*SQLiteService) UpdateCalculateNutrition ¶
func (s *SQLiteService) UpdateCalculateNutrition(userID int64, isEnabled bool) error
UpdateCalculateNutrition updates the user's calculate nutrition facts automatically setting.
func (*SQLiteService) UpdateConvertMeasurementSystem ¶
func (s *SQLiteService) UpdateConvertMeasurementSystem(userID int64, isEnabled bool) error
UpdateConvertMeasurementSystem updates the user's convert automatically setting.
func (*SQLiteService) UpdateCookbookImage ¶
UpdateCookbookImage updates the image of a user's cookbook.
func (*SQLiteService) UpdatePassword ¶
func (s *SQLiteService) UpdatePassword(userID int64, password auth.HashedPassword) error
UpdatePassword updates the user's password.
func (*SQLiteService) UpdateRecipe ¶
func (s *SQLiteService) UpdateRecipe(updatedRecipe *models.Recipe, userID int64, recipeNum int64) error
UpdateRecipe updates the recipe with its new values.
func (*SQLiteService) UpdateUserSettingsCookbooksViewMode ¶
func (s *SQLiteService) UpdateUserSettingsCookbooksViewMode(userID int64, mode models.ViewMode) error
UpdateUserSettingsCookbooksViewMode updates the user's preferred cookbooks viewing mode.
func (*SQLiteService) UserID ¶
func (s *SQLiteService) UserID(email string) int64
UserID gets the user's id from the email. It returns -1 if user not found.
func (*SQLiteService) UserInitials ¶
func (s *SQLiteService) UserInitials(userID int64) string
UserInitials gets the user's initials of maximum two characters.
func (*SQLiteService) UserSettings ¶
func (s *SQLiteService) UserSettings(userID int64) (models.UserSettings, error)
UserSettings gets the user's settings.
func (*SQLiteService) Users ¶
func (s *SQLiteService) Users() []models.User
Users gets all users in the database.
func (*SQLiteService) VerifyLogin ¶
func (s *SQLiteService) VerifyLogin(email, password string) int64
VerifyLogin checks whether the user provided correct login credentials. If yes, their user ID will be returned. Otherwise, -1 is returned.
func (*SQLiteService) Websites ¶
func (s *SQLiteService) Websites() models.Websites
Websites gets the list of supported websites from which to extract the recipe.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package statements provides SQLite statements for the service.
|
Package statements provides SQLite statements for the service. |