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

Implement user blocking #169

Closed
RiccardoM opened this issue May 19, 2020 · 6 comments · Fixed by #268
Closed

Implement user blocking #169

RiccardoM opened this issue May 19, 2020 · 6 comments · Fixed by #268
Assignees
Labels
kind/new-feature Propose the addition of a new feature that does not yet exist status/specification This feature is currently in the specification process
Milestone

Comments

@RiccardoM
Copy link
Contributor

Feature description

In all social networks, users are free to block any other user for any reason. Usually this feature is used after an abusive behavior has taken place, in order to prevent further harassment. Following the implementation of #50 and #168, I think we should definitely implement this feature also inside Desmos.

Implementation proposal

Following you can find the details of the implementation I've thought about this feature.

Types

The following type should be sufficient to represent a user blockage:

// UserBlock represents the fact that the Blocker has blocked the given Blocked user.
// The Reason field represents the reason the user has been blocked for, and is optional. 
type UserBlock struct {
  Blocker  sdk.AccAddress `json:"blocker" yaml:"blocker"`
  Blocked  sdk.AccAddress `json:"blocker" yaml:"blocker"`
  Reason   string         `json:"reason,omitempty" yaml:"reason,omitempty"`
} 

Messages

The operations that should be implemented when talking about user blocking should be:

  1. Blocking a user.
  2. Unblocking a user.

The following message should do the trick:

// MsgBlockUser allows the given Blocker to block the specified Blocked user 
// for the (optional) reason.
type MsgBlockUser struct {
  Blocker  sdk.AccAddress `json:"blocker" yaml:"blocker"`
  Blocked  sdk.AccAddress `json:"blocker" yaml:"blocker"`
  Reason   string         `json:"reason,omitempty" yaml:"reason,omitempty"`
}

// MsgUnblockUser allows the given original Blocker ot unblock the specified Blocked user.
type MsgUnblockUser struct {
  Blocker  sdk.AccAddress `json:"blocker" yaml:"blocker"`
  Blocked  sdk.AccAddress `json:"blocker" yaml:"blocker"`
}

Keeper

The following methods should be sufficient to implement all the above mentioned operations:

// SaveUserBlock allows to store the given block inside the store, returning an error if 
// something goes wrong
func (k Keeper) SaveUserBlock(ctx sdk.Context, block types.UserBlock) error {} 

// DeleteUserBlock allows to the specified blocker to unblock the given blocked user.
func (k Keeper) UnblockUser(ctx sdk.Context, blocker, blocked sdk.AccAddress) error {} 

// GetUserBlocks returns the list of users that the specified user has blocked.
func (k Keeper) GetUserBlocks(ctx sdl.Context, user sdk.AccAddress) []types.UserBlock {}

Conclusions

@kwunyeung @bragaz let me know what you guys think about this feature and its proposed implementation.

@RiccardoM RiccardoM added kind/new-feature Propose the addition of a new feature that does not yet exist x/profiles Module that allows to create and manage decentralized social profiles status/specification This feature is currently in the specification process labels May 19, 2020
@leobragaz
Copy link
Contributor

leobragaz commented May 19, 2020

Maybe this could be handled in the same way @RiccardoM suggests for the relationship.

@RiccardoM
Copy link
Contributor Author

@bragaz What do you mean by "relationship"? Could you link the issue or discussion please?

@leobragaz
Copy link
Contributor

sorry the comment is incomplete, I was referring to the fact that when you block someone on mooncake you'll have it blocked even on all the other apps, so maybe we can handle it like you suggested here: #168 (comment)

@RiccardoM RiccardoM added this to the v0.12.0 milestone Aug 31, 2020
@leobragaz
Copy link
Contributor

I think I can start with this after merge of #260

@leobragaz
Copy link
Contributor

leobragaz commented Aug 31, 2020

@RiccardoM What do you think about saving an []sdk.AccAddress instead of a UserBlock the same way we did for the relationships?
So inside the store we will have key = blocker value = []sdk.AccAddress.
We can then attach the reason of blocking inside the handler events.
Doing this I can basically extract some methods from the relationships ones and use the same code for both
saving relationship and blocking user.

@RiccardoM
Copy link
Contributor Author

@bragaz I think it's better to save the blocking reason inside the storage, otherwise it would be lost when a chain upgrade happens. Also, I think it's better to also save the blocking subspace as well to avoid that some application changes how other applications work.

@RiccardoM RiccardoM added module/relationships and removed x/profiles Module that allows to create and manage decentralized social profiles labels Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/new-feature Propose the addition of a new feature that does not yet exist status/specification This feature is currently in the specification process
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants