Skip to content

Commit 988aabc

Browse files
committed
Consolidate SafetySettings
1 parent 1ba4d46 commit 988aabc

26 files changed

Lines changed: 1826 additions & 299 deletions

API/Controller/Devices/GetShockers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public async Task<IActionResult> GetShockers([FromRoute] Guid deviceId)
3535
RfId = x.RfId,
3636
CreatedOn = x.CreatedAt,
3737
Model = x.Model,
38-
IsPaused = x.Paused
38+
IsPaused = x.IsPaused
3939
})
4040
.AsAsyncEnumerable();
4141

API/Controller/Public/PublicShareController.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ public async Task<IActionResult> GetShareLink([FromRoute] Guid shareLinkId)
4646
Name = y.Shocker.Name,
4747
Limits = new ShockerLimits
4848
{
49-
Duration = y.LimitDuration,
50-
Intensity = y.LimitIntensity
49+
Intensity = y.MaxIntensity,
50+
Duration = y.MaxDuration
5151
},
5252
Permissions = new ShockerPermissions
5353
{
54-
Vibrate = y.PermVibrate,
55-
Sound = y.PermSound,
56-
Shock = y.PermShock,
57-
Live = y.PermLive
54+
Vibrate = y.AllowVibrate,
55+
Sound = y.AllowSound,
56+
Shock = y.AllowShock,
57+
Live = y.AllowLiveControl
5858
},
59-
Paused = ShareLinkUtils.GetPausedReason(y.Paused, y.Shocker.Paused),
59+
Paused = ShareLinkUtils.GetPausedReason(y.IsPaused, y.Shocker.IsPaused),
6060
}
6161
})
6262
}).FirstOrDefaultAsync();

API/Controller/Shares/LinkShareCode.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ [FromServices] IDeviceUpdateService deviceUpdateService
4444
{
4545
SharedWith = CurrentUser.Id,
4646
ShockerId = shareCode.Share.ShockerId,
47-
PermSound = shareCode.Share.PermSound,
48-
PermVibrate = shareCode.Share.PermVibrate,
49-
PermShock = shareCode.Share.PermShock,
50-
LimitDuration = shareCode.Share.LimitDuration,
51-
LimitIntensity = shareCode.Share.LimitIntensity,
52-
PermLive = true
47+
AllowShock = shareCode.Share.AllowShock,
48+
AllowVibrate = shareCode.Share.AllowVibrate,
49+
AllowSound = shareCode.Share.AllowSound,
50+
AllowLiveControl = shareCode.Share.AllowLiveControl,
51+
MaxIntensity = shareCode.Share.MaxIntensity,
52+
MaxDuration = shareCode.Share.MaxDuration,
53+
IsPaused = shareCode.Share.IsPaused
5354
});
5455
_db.ShockerShareCodes.Remove(shareCode.Share);
5556

API/Controller/Shares/Links/AddShocker.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ public async Task<IActionResult> AddShocker([FromRoute] Guid shareLinkId, [FromR
3838
{
3939
ShockerId = shockerId,
4040
ShareLinkId = shareLinkId,
41-
PermSound = true,
42-
PermVibrate = true,
43-
PermShock = true
41+
AllowShock = true,
42+
AllowVibrate = true,
43+
AllowSound = true,
44+
AllowLiveControl = false,
45+
IsPaused = false
4446
});
4547

4648
await _db.SaveChangesAsync();

API/Controller/Shares/Links/EditShockerShareLink.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ await _db.ShockerSharesLinksShockers.FirstOrDefaultAsync(x =>
3333
x.ShareLinkId == shareLinkId && x.ShockerId == shockerId);
3434
if (shocker == null) return Problem(ShareLinkError.ShockerNotInShareLink);
3535

36-
shocker.PermSound = body.Permissions.Sound;
37-
shocker.PermVibrate = body.Permissions.Vibrate;
38-
shocker.PermShock = body.Permissions.Shock;
39-
shocker.LimitDuration = body.Limits.Duration;
40-
shocker.LimitIntensity = body.Limits.Intensity;
41-
shocker.PermLive = body.Permissions.Live;
36+
shocker.AllowShock = body.Permissions.Shock;
37+
shocker.AllowVibrate = body.Permissions.Vibrate;
38+
shocker.AllowSound = body.Permissions.Sound;
39+
shocker.AllowLiveControl = body.Permissions.Live;
40+
shocker.MaxIntensity = body.Limits.Intensity;
41+
shocker.MaxDuration = body.Limits.Duration;
4242
shocker.Cooldown = body.Cooldown;
4343

4444
await _db.SaveChangesAsync();

API/Controller/Shares/Links/PauseShockerShareLink.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ await _db.ShockerSharesLinksShockers.Where(x =>
3333
x.ShareLinkId == shareLinkId && x.ShockerId == shockerId).Include(x => x.Shocker).FirstOrDefaultAsync();
3434
if (shocker == null) return Problem(ShareLinkError.ShockerNotInShareLink);
3535

36-
shocker.Paused = body.Pause;
36+
shocker.IsPaused = body.Pause;
3737
await _db.SaveChangesAsync();
3838

39-
return LegacyDataOk(ShareLinkUtils.GetPausedReason(shocker.Paused, shocker.Shocker.Paused));
39+
return LegacyDataOk(ShareLinkUtils.GetPausedReason(shocker.IsPaused, shocker.Shocker.IsPaused));
4040
}
4141
}

API/Controller/Shares/V2CreateShareRequest.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ public async Task<IActionResult> CreateShare([FromBody] CreateShareRequest data)
6161
{
6262
ShareRequest = shareRequest.Id,
6363
Shocker = createShockerShare.Id,
64-
LimitDuration = createShockerShare.Limits.Duration,
65-
LimitIntensity = createShockerShare.Limits.Intensity,
66-
PermLive = createShockerShare.Permissions.Live,
67-
PermShock = createShockerShare.Permissions.Shock,
68-
PermSound = createShockerShare.Permissions.Sound,
69-
PermVibrate = createShockerShare.Permissions.Vibrate
64+
AllowShock = createShockerShare.Permissions.Shock,
65+
AllowVibrate = createShockerShare.Permissions.Vibrate,
66+
AllowSound = createShockerShare.Permissions.Sound,
67+
AllowLiveControl = createShockerShare.Permissions.Live,
68+
MaxIntensity = createShockerShare.Limits.Intensity,
69+
MaxDuration = createShockerShare.Limits.Duration,
70+
IsPaused = false
7071
});
7172
}
7273

API/Controller/Shares/V2GetShares.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ public IAsyncEnumerable<V2UserSharesListItem> GetSharesByUsers()
2828
CreatedOn = y.CreatedAt,
2929
Permissions = new ShockerPermissions
3030
{
31-
Sound = y.PermSound,
32-
Vibrate = y.PermVibrate,
33-
Shock = y.PermShock,
34-
Live = y.PermLive
31+
Vibrate = y.AllowVibrate,
32+
Sound = y.AllowSound,
33+
Shock = y.AllowShock,
34+
Live = y.AllowLiveControl
3535
},
3636
Limits = new ShockerLimits
3737
{
38-
Duration = y.LimitDuration,
39-
Intensity = y.LimitIntensity
38+
Intensity = y.MaxIntensity,
39+
Duration = y.MaxDuration
4040
},
41-
Paused = y.Paused
41+
Paused = y.IsPaused
4242
})
4343
.ToArray()
4444
})

API/Controller/Shares/V2Requests.cs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public IAsyncEnumerable<ShareRequestBaseDetails> GetOutgoingRequestsList()
4343
Id = y.Shocker,
4444
Limits = new ShockerLimits
4545
{
46-
Duration = y.LimitDuration,
47-
Intensity = y.LimitIntensity
46+
Intensity = y.MaxIntensity,
47+
Duration = y.MaxDuration
4848
},
4949
Permissions = new ShockerPermissions
5050
{
51-
Shock = y.PermShock,
52-
Sound = y.PermSound,
53-
Vibrate = y.PermVibrate,
54-
Live = y.PermLive
51+
Vibrate = y.AllowVibrate,
52+
Sound = y.AllowSound,
53+
Shock = y.AllowShock,
54+
Live = y.AllowLiveControl
5555
}
5656
})
5757
}).AsAsyncEnumerable();
@@ -85,15 +85,15 @@ public IAsyncEnumerable<ShareRequestBaseDetails> GetIncomingRequestsList()
8585
Id = y.Shocker,
8686
Limits = new ShockerLimits
8787
{
88-
Duration = y.LimitDuration,
89-
Intensity = y.LimitIntensity
88+
Duration = y.MaxDuration,
89+
Intensity = y.MaxIntensity
9090
},
9191
Permissions = new ShockerPermissions
9292
{
93-
Shock = y.PermShock,
94-
Sound = y.PermSound,
95-
Vibrate = y.PermVibrate,
96-
Live = y.PermLive
93+
Vibrate = y.AllowVibrate,
94+
Sound = y.AllowSound,
95+
Shock = y.AllowShock,
96+
Live = y.AllowLiveControl
9797
}
9898
})
9999
}).AsAsyncEnumerable();
@@ -151,25 +151,27 @@ public async Task<IActionResult> RedeemRequest(Guid id, [FromServices] IDeviceUp
151151
var existingShare = alreadySharedShockers.FirstOrDefault(x => x.ShockerId == shareRequestShocker.Shocker);
152152
if (existingShare != null)
153153
{
154-
existingShare.PermShock = shareRequestShocker.PermShock;
155-
existingShare.PermSound = shareRequestShocker.PermSound;
156-
existingShare.PermVibrate = shareRequestShocker.PermVibrate;
157-
existingShare.PermLive = shareRequestShocker.PermLive;
158-
existingShare.LimitDuration = shareRequestShocker.LimitDuration;
159-
existingShare.LimitIntensity = shareRequestShocker.LimitIntensity;
154+
existingShare.AllowShock = shareRequestShocker.AllowShock;
155+
existingShare.AllowVibrate = shareRequestShocker.AllowVibrate;
156+
existingShare.AllowSound = shareRequestShocker.AllowSound;
157+
existingShare.AllowLiveControl = shareRequestShocker.AllowLiveControl;
158+
existingShare.MaxIntensity = shareRequestShocker.MaxIntensity;
159+
existingShare.MaxDuration = shareRequestShocker.MaxDuration;
160+
existingShare.IsPaused = shareRequestShocker.IsPaused;
160161
}
161162
else
162163
{
163164
var newShare = new ShockerShare
164165
{
165166
ShockerId = shareRequestShocker.Shocker,
166167
SharedWith = CurrentUser.Id,
167-
PermShock = shareRequestShocker.PermShock,
168-
PermSound = shareRequestShocker.PermSound,
169-
PermVibrate = shareRequestShocker.PermVibrate,
170-
PermLive = shareRequestShocker.PermLive,
171-
LimitDuration = shareRequestShocker.LimitDuration,
172-
LimitIntensity = shareRequestShocker.LimitIntensity
168+
AllowShock = shareRequestShocker.AllowShock,
169+
AllowVibrate = shareRequestShocker.AllowVibrate,
170+
AllowSound = shareRequestShocker.AllowSound,
171+
AllowLiveControl = shareRequestShocker.AllowLiveControl,
172+
MaxIntensity = shareRequestShocker.MaxIntensity,
173+
MaxDuration = shareRequestShocker.MaxDuration,
174+
IsPaused = shareRequestShocker.IsPaused
173175
};
174176

175177
alreadySharedShockers.Add(newShare);

API/Controller/Shockers/GetShockerById.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public async Task<IActionResult> GetShockerById([FromRoute] Guid shockerId)
3131
CreatedOn = x.CreatedAt,
3232
Device = x.Device,
3333
Model = x.Model,
34-
IsPaused = x.Paused
34+
IsPaused = x.IsPaused
3535
}).FirstOrDefaultAsync();
3636

3737
if (shocker == null) return Problem(ShockerError.ShockerNotFound);

0 commit comments

Comments
 (0)