mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-25 23:18:44 -07:00
Refactor room visibility logic: enhance filtering criteria for public rooms and update related comments for clarity
This commit is contained in:
@@ -134,14 +134,18 @@ public class PublicSiteController(
|
||||
{
|
||||
var clamped = Math.Clamp(take, 1, 50);
|
||||
var qq = (q ?? string.Empty).Trim();
|
||||
// Public rooms list: hide dorms (per-player private space), and
|
||||
// hide rooms that have only ever been visited by their creator
|
||||
// (VisitorCount < 2). This keeps "^dwadwad" style throwaway
|
||||
// builds off the public-facing site without an explicit
|
||||
// "publish" toggle. Admins can still see them via the Rooms
|
||||
// admin page and delete them from there if they want.
|
||||
// Public rooms list: hide archived, private/friends-only,
|
||||
// dorm, and admin-hidden rows. Also hide rooms that have only
|
||||
// ever been visited by their creator (VisitorCount < 2). This
|
||||
// keeps throwaway builds off the public-facing site without an
|
||||
// explicit "publish" toggle. Admins can still see them via the
|
||||
// Rooms admin page and delete them from there if they want.
|
||||
var rows = await db.Rooms
|
||||
.Where(r => !r.IsDormRoom && r.VisitorCount >= 2 &&
|
||||
.Where(r => r.State == 0 &&
|
||||
r.Accessibility == 1 &&
|
||||
!r.IsDormRoom &&
|
||||
!r.HiddenFromBrowse &&
|
||||
r.VisitorCount >= 2 &&
|
||||
(qq == "" || r.Name.Contains(qq) || r.Description.Contains(qq)))
|
||||
.OrderByDescending(r => r.HotScore)
|
||||
.Take(clamped)
|
||||
@@ -171,7 +175,11 @@ public class PublicSiteController(
|
||||
public async Task<IActionResult> Stats()
|
||||
{
|
||||
var playerCount = await db.Players.CountAsync();
|
||||
var roomCount = await db.Rooms.CountAsync(r => !r.IsDormRoom);
|
||||
var roomCount = await db.Rooms.CountAsync(r =>
|
||||
r.State == 0 &&
|
||||
r.Accessibility == 1 &&
|
||||
!r.IsDormRoom &&
|
||||
!r.HiddenFromBrowse);
|
||||
var photoCount = await db.Photos.CountAsync(p => p.IsPublic && p.DeletedAt == null);
|
||||
var inventionCount = await db.Inventions.CountAsync(i => !i.IsDeleted);
|
||||
return Ok(new { playerCount, roomCount, photoCount, inventionCount });
|
||||
@@ -212,7 +220,11 @@ public class PublicSiteController(
|
||||
.Select(p => new { p.Id, p.Username, p.DisplayName, p.ProfileImageName })
|
||||
.ToListAsync();
|
||||
var rooms = await db.Rooms
|
||||
.Where(r => roomIds.Contains(r.Id))
|
||||
.Where(r => roomIds.Contains(r.Id) &&
|
||||
r.State == 0 &&
|
||||
r.Accessibility == 1 &&
|
||||
!r.IsDormRoom &&
|
||||
!r.HiddenFromBrowse)
|
||||
.Select(r => new { r.Id, r.Name })
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
@@ -2043,15 +2043,6 @@
|
||||
"item_outfit_type": 0,
|
||||
"mask_guid": ""
|
||||
},
|
||||
{
|
||||
"swatch_name": "CheerDress_Blue_Swatch",
|
||||
"swatch_guid": "faedf215-289b-40f7-90cc-f5b98517d133",
|
||||
"color": "Blue",
|
||||
"item_name": "(FemaleCheerTorso)",
|
||||
"item_guid": "657efe89-620a-46a2-8b58-cafd855c7cd5",
|
||||
"item_outfit_type": 101,
|
||||
"mask_guid": "93987d32-7a6e-45df-af56-76f912969ce7"
|
||||
},
|
||||
{
|
||||
"swatch_name": "PirateCaptain_Hat_SRank_Swatch",
|
||||
"swatch_guid": "jQwNBXyoU0Gk4FyNw6jFxg",
|
||||
@@ -2385,15 +2376,6 @@
|
||||
"item_outfit_type": 0,
|
||||
"mask_guid": "efeb07ab-6253-436d-bb66-991ddad72e58"
|
||||
},
|
||||
{
|
||||
"swatch_name": "CheerDress_Red_Swatch",
|
||||
"swatch_guid": "1773d5d8-4714-4721-b30c-97e25d6f2a5a",
|
||||
"color": "Red",
|
||||
"item_name": "(FemaleCheerTorso)",
|
||||
"item_guid": "657efe89-620a-46a2-8b58-cafd855c7cd5",
|
||||
"item_outfit_type": 101,
|
||||
"mask_guid": "93987d32-7a6e-45df-af56-76f912969ce7"
|
||||
},
|
||||
{
|
||||
"swatch_name": "Golfer_Glove_Blue_Swatch",
|
||||
"swatch_guid": "32a5e42d-2b60-40b1-a145-ed96fc91af8e",
|
||||
@@ -3837,6 +3819,7 @@
|
||||
"Cyber_Junk_City_Swatch",
|
||||
"BicycleJacket_DarkBlue_Swatch",
|
||||
"Torso_SeaCaptainBlueWhite_Swatch",
|
||||
"CheerDress_Blue_Swatch",
|
||||
"Denim_Swatch",
|
||||
"RoyalLady_Contest_White_Swatch",
|
||||
"Neck_VampiteHunter_Diamond_Swatch",
|
||||
@@ -3852,6 +3835,7 @@
|
||||
"GoldYellow_Swatch",
|
||||
"Happy_Tree_Purple_Swatch",
|
||||
"Barber_Torso_Green_Swatch",
|
||||
"CheerDress_Red_Swatch",
|
||||
"TShirt_RECS_Logo_Blue_Swatch",
|
||||
"Scout_Shirt_Blue_Swatch",
|
||||
"Windbreaker_Wrist_Red_Swatch",
|
||||
|
||||
@@ -558,11 +558,18 @@ public class RoomService(DorkNetDbContext db)
|
||||
// and have no business appearing in the watch's public room
|
||||
// browser (Trending / Search / BaseRooms all reach this query).
|
||||
// Same filter applied below to SearchAsync and CreatedByAsync.
|
||||
// Accessibility=1 is Public. Private/Friends-only rooms should
|
||||
// still be reachable by direct goto/invite/owned-room APIs, but
|
||||
// must not leak into public discovery.
|
||||
// HiddenFromBrowse keeps admin-utility rooms (MakerRoom,
|
||||
// EventRoom) and rooms-folded-into-others (Paintball maps,
|
||||
// LaserTag Hangar) out of every public discovery surface.
|
||||
// /goto-by-name and admin tools still find them via GetByNameAsync.
|
||||
IQueryable<RoomEntity> q = db.Rooms.Where(r => r.State == 0 && !r.IsDormRoom && !r.HiddenFromBrowse);
|
||||
IQueryable<RoomEntity> q = db.Rooms.Where(r =>
|
||||
r.State == 0 &&
|
||||
r.Accessibility == 1 &&
|
||||
!r.IsDormRoom &&
|
||||
!r.HiddenFromBrowse);
|
||||
if (!string.IsNullOrWhiteSpace(tag))
|
||||
{
|
||||
var bareTag = tag.TrimStart('#').Trim();
|
||||
@@ -621,7 +628,11 @@ public class RoomService(DorkNetDbContext db)
|
||||
if (accountId is long aid)
|
||||
{
|
||||
return await db.Rooms
|
||||
.Where(r => r.CreatorPlayerId == aid && !r.IsDormRoom && r.State == 0)
|
||||
.Where(r => r.CreatorPlayerId == aid &&
|
||||
r.State == 0 &&
|
||||
r.Accessibility == 1 &&
|
||||
!r.IsDormRoom &&
|
||||
!r.HiddenFromBrowse)
|
||||
.OrderByDescending(r => r.UpdatedAt)
|
||||
.Take(take)
|
||||
.ToListAsync();
|
||||
@@ -634,7 +645,10 @@ public class RoomService(DorkNetDbContext db)
|
||||
|
||||
var needle = $"%{query}%";
|
||||
return await db.Rooms
|
||||
.Where(r => r.State == 0 && !r.IsDormRoom && !r.HiddenFromBrowse && (
|
||||
.Where(r => r.State == 0 &&
|
||||
r.Accessibility == 1 &&
|
||||
!r.IsDormRoom &&
|
||||
!r.HiddenFromBrowse && (
|
||||
EF.Functions.Like(r.Name, needle) ||
|
||||
EF.Functions.Like(r.Description, needle) ||
|
||||
EF.Functions.Like(r.TagsCsv, needle)))
|
||||
|
||||
Reference in New Issue
Block a user