Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
when adding an RO to the list when booting up, set the opt-in status …
Browse files Browse the repository at this point in the history
…and date

fixes #161
  • Loading branch information
Kevin Hunter committed May 27, 2016
1 parent b326cfd commit 951ae80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion source/SOCVR.Chatbot/Database/DatabaseContext.cs
Expand Up @@ -68,13 +68,21 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
/// If it does not exist, the user entry will be created.
/// </summary>
/// <param name="profileId"></param>
public void EnsureUserExists(int profileId)
/// <param name="setOptIn">If true, the user will be opted in to user tracking.</param>
public void EnsureUserExists(int profileId, bool setOptIn = false)
{
var dbUser = Users.SingleOrDefault(x => x.ProfileId == profileId);

if (dbUser == null)
{
dbUser = new User() { ProfileId = profileId };

if (setOptIn)
{
dbUser.LastTrackingPreferenceChange = DateTimeOffset.Now;
dbUser.OptInToReviewTracking = true;
}

Users.Add(dbUser);
SaveChanges();
}
Expand Down
2 changes: 1 addition & 1 deletion source/SOCVR.Chatbot/Program.cs
Expand Up @@ -89,7 +89,7 @@ private static void EnsureRoomOwnersAreInDatabase(DatabaseContext db)

foreach (var ro in roList)
{
db.EnsureUserExists(ro.ID);
db.EnsureUserExists(ro.ID, true);
db.EnsureUserIsInAllPermissionGroups(ro.ID);
}
}
Expand Down

0 comments on commit 951ae80

Please sign in to comment.