fix: don't leak the existence of private info in lists (#412)
This commit is contained in:
parent
50a24f03a7
commit
f08524ee19
@ -132,7 +132,7 @@ public static class ContextListExt
|
|||||||
}
|
}
|
||||||
case SortProperty.DisplayName:
|
case SortProperty.DisplayName:
|
||||||
{
|
{
|
||||||
if (m.DisplayName != null)
|
if (m.DisplayName != null && m.NamePrivacy.CanAccess(lookupCtx))
|
||||||
ret += $"({m.DisplayName})";
|
ret += $"({m.DisplayName})";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -89,23 +89,26 @@ public static class MemberListOptionsExt
|
|||||||
// We want nulls last no matter what, even if orders are reversed
|
// We want nulls last no matter what, even if orders are reversed
|
||||||
SortProperty.Hid => input.OrderBy(m => m.Hid, ReverseMaybe(culture)),
|
SortProperty.Hid => input.OrderBy(m => m.Hid, ReverseMaybe(culture)),
|
||||||
SortProperty.Name => input.OrderBy(m => m.NameFor(ctx), ReverseMaybe(culture)),
|
SortProperty.Name => input.OrderBy(m => m.NameFor(ctx), ReverseMaybe(culture)),
|
||||||
SortProperty.CreationDate => input.OrderBy(m => m.Created, ReverseMaybe(Comparer<Instant>.Default)),
|
SortProperty.CreationDate => input
|
||||||
SortProperty.MessageCount => input.OrderByDescending(m => m.MessageCount,
|
.OrderByDescending(m => m.MetadataPrivacy.CanAccess(ctx))
|
||||||
ReverseMaybe(Comparer<int>.Default)),
|
.ThenBy(m => m.MetadataPrivacy.Get(ctx, m.Created, default), ReverseMaybe(Comparer<Instant>.Default)),
|
||||||
|
SortProperty.MessageCount => input
|
||||||
|
.OrderByDescending(m => m.MessageCount != 0 && m.MetadataPrivacy.CanAccess(ctx))
|
||||||
|
.ThenByDescending(m => m.MetadataPrivacy.Get(ctx, m.MessageCount, 0), ReverseMaybe(Comparer<int>.Default)),
|
||||||
SortProperty.DisplayName => input
|
SortProperty.DisplayName => input
|
||||||
.OrderByDescending(m => m.DisplayName != null)
|
.OrderByDescending(m => m.DisplayName != null && m.NamePrivacy.CanAccess(ctx))
|
||||||
.ThenBy(m => m.DisplayName, ReverseMaybe(culture)),
|
.ThenBy(m => m.NamePrivacy.Get(ctx, m.DisplayName), ReverseMaybe(culture)),
|
||||||
SortProperty.Birthdate => input
|
SortProperty.Birthdate => input
|
||||||
.OrderByDescending(m => m.AnnualBirthday.HasValue)
|
.OrderByDescending(m => m.AnnualBirthday.HasValue && m.BirthdayPrivacy.CanAccess(ctx))
|
||||||
.ThenBy(m => m.AnnualBirthday, ReverseMaybe(Comparer<AnnualDate?>.Default)),
|
.ThenBy(m => m.BirthdayPrivacy.Get(ctx, m.AnnualBirthday), ReverseMaybe(Comparer<AnnualDate?>.Default)),
|
||||||
SortProperty.LastMessage => throw new PKError(
|
SortProperty.LastMessage => throw new PKError(
|
||||||
"Sorting by last message is temporarily disabled due to database issues, sorry."),
|
"Sorting by last message is temporarily disabled due to database issues, sorry."),
|
||||||
// SortProperty.LastMessage => input
|
// SortProperty.LastMessage => input
|
||||||
// .OrderByDescending(m => m.LastMessage.HasValue)
|
// .OrderByDescending(m => m.LastMessage.HasValue)
|
||||||
// .ThenByDescending(m => m.LastMessage, ReverseMaybe(Comparer<ulong?>.Default)),
|
// .ThenByDescending(m => m.LastMessage, ReverseMaybe(Comparer<ulong?>.Default)),
|
||||||
SortProperty.LastSwitch => input
|
SortProperty.LastSwitch => input
|
||||||
.OrderByDescending(m => m.LastSwitchTime.HasValue)
|
.OrderByDescending(m => m.LastSwitchTime.HasValue && m.MetadataPrivacy.CanAccess(ctx))
|
||||||
.ThenByDescending(m => m.LastSwitchTime, ReverseMaybe(Comparer<Instant?>.Default)),
|
.ThenByDescending(m => m.MetadataPrivacy.Get(ctx, m.LastSwitchTime), ReverseMaybe(Comparer<Instant?>.Default)),
|
||||||
SortProperty.Random => input
|
SortProperty.Random => input
|
||||||
.OrderBy(m => randGen.Next()),
|
.OrderBy(m => randGen.Next()),
|
||||||
_ => throw new ArgumentOutOfRangeException($"Unknown sort property {opts.SortProperty}")
|
_ => throw new ArgumentOutOfRangeException($"Unknown sort property {opts.SortProperty}")
|
||||||
|
Loading…
Reference in New Issue
Block a user