🐛 Fixes for relationships
This commit is contained in:
parent
88977ccda3
commit
b489a79df2
@ -108,6 +108,11 @@ public class RelationshipController(AppDatabase db, RelationshipService rels) :
|
|||||||
var relatedUser = await db.Accounts.FindAsync(userId);
|
var relatedUser = await db.Accounts.FindAsync(userId);
|
||||||
if (relatedUser is null) return NotFound("Account was not found.");
|
if (relatedUser is null) return NotFound("Account was not found.");
|
||||||
|
|
||||||
|
var existing = await db.AccountRelationships.FirstOrDefaultAsync(r =>
|
||||||
|
(r.AccountId == currentUser.Id && r.RelatedId == userId) ||
|
||||||
|
(r.AccountId == userId && r.RelatedId == currentUser.Id));
|
||||||
|
if (existing != null) return BadRequest("Relationship already exists.");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var relationship = await rels.SendFriendRequest(currentUser, relatedUser);
|
var relationship = await rels.SendFriendRequest(currentUser, relatedUser);
|
||||||
|
@ -263,7 +263,7 @@ public static class PostQueryExtensions
|
|||||||
.Where(e => e.Visibility == PostVisibility.Public);
|
.Where(e => e.Visibility == PostVisibility.Public);
|
||||||
|
|
||||||
return source
|
return source
|
||||||
.Where(e => e.PublishedAt != null && now >= e.PublishedAt && e.Publisher.AccountId == currentUser.Id)
|
.Where(e => (e.PublishedAt != null && now >= e.PublishedAt) || e.Publisher.AccountId == currentUser.Id)
|
||||||
.Where(e => e.Visibility != PostVisibility.Private || e.Publisher.AccountId == currentUser.Id)
|
.Where(e => e.Visibility != PostVisibility.Private || e.Publisher.AccountId == currentUser.Id)
|
||||||
.Where(e => e.Visibility != PostVisibility.Friends ||
|
.Where(e => e.Visibility != PostVisibility.Friends ||
|
||||||
(e.Publisher.AccountId != null && userFriends.Contains(e.Publisher.AccountId.Value)) ||
|
(e.Publisher.AccountId != null && userFriends.Contains(e.Publisher.AccountId.Value)) ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user