Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: blocked by peer status #5732

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion browser-interface/packages/shared/comms/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ async function stripSnapshots(profile: Avatar): Promise<Avatar> {
...profile,
avatar: { ...profile.avatar, snapshots: newSnapshots as Snapshots },
// THIS IS IMPORTANT, the blocked and muted sizes are too big for the network and are unnecesary
blocked: [],
// blocked status propagation has been re-enabled so the current user knows when a peer has blocked it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't messages be ignored locally instead? I'm worried about the big warning above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the warning in the comment "the blocked and muted sizes are too big for the network", can we simply ignore the messages if we get one from a blocked user?

Copy link
Collaborator Author

@lorux0 lorux0 Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not only the chat messages. You shouldnt be able to interact with friend requests or preview the passport of peers that blocked you. We have special states in the UI for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, understood, but I don't think we can simply send this through comms, some users have thousands of addresses in the block list, and this message is broadcasted to everyone around the user.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to make a workaround by fetching the user profile from the catalyst when this information is required

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to fetch the blocked list from the catalyst when needed adds too much complexity thus a mess to handle with the current architecture. A new proposal is coming on which profile information will always be fetched from the catalyst instead of being broadcasted through comms. This way would fix the problem

// use case: you shouldn't be able to send messages or friend requests to peers that blocked you
// blocked: [],
muted: []
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private async UniTask UpdateWithUserProfileAsync(UserProfile userProfile, Cancel
presenceStatus = friendsController.GetUserStatus(userProfile.userId).presence,
isGuest = userProfile.isGuest,
isBlocked = ownUserProfile.IsBlocked(userProfile.userId),
hasBlocked = userProfile.IsBlocked(ownUserProfile.userId),
isBlockedByPeer = userProfile.IsBlocked(ownUserProfile.userId),
friendshipStatus = await friendsController.GetFriendshipStatus(userProfile.userId, cancellationToken),
isFriendshipVisible = isFriendsEnabled && friendsController.IsInitialized,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public class PassportPlayerInfoComponentView : BaseComponentView<PlayerPassportM

private string fullWalletAddress;
private bool areFriends;
private bool isBlocked = false;
private Dictionary<FriendshipStatus, GameObject> friendStatusButtonsMapping;
private CancellationTokenSource cts;

Expand Down Expand Up @@ -115,7 +114,7 @@ public override void RefreshControl()
SetWallet(model.userId);
SetPresence(model.presenceStatus);
SetIsBlocked(model.isBlocked);
SetHasBlockedOwnUser(model.hasBlocked);
SetIsBlockedByPeer(model.isBlockedByPeer);
SetFriendStatus(model.friendshipStatus);
SetFriendshipVisibility(model.isFriendshipVisible);
}
Expand Down Expand Up @@ -151,7 +150,7 @@ public void SetFriendStatus(FriendshipStatus friendStatus)
{
areFriends = friendStatus == FriendshipStatus.FRIEND;

if (isBlocked)
if (model.isBlocked || model.isBlockedByPeer)
return;

DisableAllFriendFlowButtons();
Expand Down Expand Up @@ -191,14 +190,16 @@ private void SetWallet(string wallet)

public void SetIsBlocked(bool isBlocked)
{
this.isBlocked = isBlocked;
model.isBlocked = isBlocked;

DisableAllFriendFlowButtons();

blockedFriendButton.gameObject.SetActive(isBlocked);
optionsContainer.SetActive(!isBlocked);
blockedLabel.SetActive(isBlocked);

if (!isBlocked) { SetFriendStatus(model.friendshipStatus); }
if (!isBlocked && !model.isBlockedByPeer)
SetFriendStatus(model.friendshipStatus);
}

public void SetActionsActive(bool isActive) =>
Expand All @@ -223,9 +224,10 @@ private void SetGuestUser(bool isGuest)
normalUserPanel.SetActive(!isGuest);
}

private void SetHasBlockedOwnUser(bool hasBlocked)
private void SetIsBlockedByPeer(bool hasBlocked)
{
friendsFlowContainer.SetActive(!hasBlocked);
DisableAllFriendFlowButtons();
}

private void DisableAllFriendFlowButtons()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public record PlayerPassportModel
public PresenceStatus presenceStatus;
public bool isGuest;
public bool isBlocked;
public bool hasBlocked;
public bool isBlockedByPeer;
public FriendshipStatus friendshipStatus;
public bool isFriendshipVisible;
}
Loading
Loading