Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new methods for managing visitor settings (for personalization) #2591

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions Oqtane.Client/Services/Interfaces/ISettingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public interface ISettingService
/// <summary>
/// Returns a key-value dictionary of all page module settings for the given page module
/// </summary>
/// <param name="pageId"></param>
/// <param name="pageModuleId"></param>
/// <returns></returns>
Task<Dictionary<string, string>> GetPageModuleSettingsAsync(int pageModuleId);

Expand Down Expand Up @@ -107,7 +107,7 @@ public interface ISettingService
/// <summary>
/// Returns a key-value dictionary of all user settings for the given user
/// </summary>
/// <param name="pageId"></param>
/// <param name="userId"></param>
/// <returns></returns>
Task<Dictionary<string, string>> GetUserSettingsAsync(int userId);

Expand All @@ -122,7 +122,7 @@ public interface ISettingService
/// <summary>
/// Returns a key-value dictionary of all folder settings for the given folder
/// </summary>
/// <param name="pageId"></param>
/// <param name="folderId"></param>
/// <returns></returns>
Task<Dictionary<string, string>> GetFolderSettingsAsync(int folderId);

Expand All @@ -148,6 +148,21 @@ public interface ISettingService
/// <returns></returns>
Task UpdateHostSettingsAsync(Dictionary<string, string> hostSettings);

/// <summary>
/// Returns a key-value dictionary of all settings for the given visitor
/// </summary>
/// <param name="visitorId"></param>
/// <returns></returns>
Task<Dictionary<string, string>> GetVisitorSettingsAsync(int visitorId);

/// <summary>
/// Updates a visitor setting
/// </summary>
/// <param name="visitorSettings"></param>
/// <param name="visitorId"></param>
/// <returns></returns>
Task UpdateVisitorSettingsAsync(Dictionary<string, string> visitorSettings, int visitorId);

/// <summary>
/// Returns a key-value dictionary of all settings for the given entityName
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions Oqtane.Client/Services/SettingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ public async Task UpdateHostSettingsAsync(Dictionary<string, string> hostSetting
await UpdateSettingsAsync(hostSettings, EntityNames.Host, -1);
}

public async Task<Dictionary<string, string>> GetVisitorSettingsAsync(int visitorId)
{
if (visitorId != -1)
{
return await GetSettingsAsync(EntityNames.Visitor, visitorId);
}
else
{
return new Dictionary<string, string>();
}
}

public async Task UpdateVisitorSettingsAsync(Dictionary<string, string> visitorSettings, int visitorId)
{
if (visitorId != -1)
{
await UpdateSettingsAsync(visitorSettings, EntityNames.Visitor, visitorId);
}
}

public async Task<Dictionary<string, string>> GetSettingsAsync(string entityName, int entityId)
{
var dictionary = new Dictionary<string, string>();
Expand Down
1 change: 0 additions & 1 deletion Oqtane.Server/Controllers/SettingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ private bool IsAuthorized(string entityName, int entityId, string permissionName
{
authorized = (visitorId == entityId);
}
authorized = false;
}
break;
default: // custom entity
Expand Down