Block a user
If you are the website owner, you can block users by adding their signing key to the appendable data associated with the current page.
Contents

Get the signing key of a user
The plugin fetches the signing key of the user you want to block.
GET /appendable-data/sign-key/:handleId/:index
controller.js
window.safeAppendableData.getSignKeyAt(this._authToken, this._currentPostHandleId, index)
Add the signing key to the filter
The plugin adds the signing key of the user you want to block to the filter of the appendable data associated with the current page. Since the filter of the appendable data is a blacklist, everyone except the keys listed in the filter will be allowed to append data.
PUT /appendable-data/filter/:handleId
controller.js
window.safeAppendableData.addToFilter(this._authToken, this._currentPostHandleId, [signKeyHandleId])
Save the appendable data
The plugin updates the appendable data associated with the current page by sending a POST request to the SAFE Network.
POST /appendable-data/:handleId
controller.js
window.safeAppendableData.post(this._authToken, this._currentPostHandleId)
Whenever you block a user, the plugin adds their public name and their signing key to a structured data associated with the current page. Using this list of blocked users, you can unblock a user based on their public name.
controller.js
this._saveBlockedUser(userName, signKeyHandleId)
Serialize the signing key
The plugins serializes the signing key of the user you want to block.
GET /sign-key/serialise/:handleId
controller.js
window.safeSignKey.serialise(this._authToken, signKeyHandle)
If the structured data for blocked users is found
The plugin adds the serialized signing key of the user you want to block to the list of block users for the current page.
controller.js
this._data.blockedUsers[userName] = serialisedSignKey
Update the structured data
The plugin updates the structured data with the new list of block users.
PATCH /structured-data/:handleId
controller.js
window.safeStructuredData.updateData(
this._authToken,
this._blockedUserStructureDataHandle,
new Buffer(JSON.stringify(this._data.blockedUsers)).toString('base64'), this._symmetricCipherOptsHandle)
Save existing structured data
The plugin saves the structured data by sending a POST request to the SAFE Network.
POST /structured-data/:handleId
controller.js
window.safeStructuredData.post(
this._authToken,
this._blockedUserStructureDataHandle)
After the user has been blocked, the plugin reloads the comments.
If the structured data for blocked users is not found
The plugin creates a new structured data based on the URL of the current page. This structured data will be used to store the list of blocked users for the current page. Whenever you want to block a user, the plugin will add their public name and their signing key to that structured data.
Create a structured data
The plugin creates a new structured data that contains the public name and the serialized signing key of the user you want to block.
controller.js
this._data.blockedUsers = {}
this._data.blockedUsers[userName] = serialisedSignKey
POST /structured-data
controller.js
window.safeStructuredData.create(
this._authToken,
this._getLocation() + '_blocked_users', 500,
new Buffer(JSON.stringify(this._data.blockedUsers)).toString('base64'),
this._symmetricCipherOptsHandle)
Save new structured data
The plugin saves this new structured data by sending a PUT request to the SAFE Network.
PUT /structured-data/:handleId
controller.js
window.safeStructuredData.put(
this._authToken,
this._blockedUserStructureDataHandle)
After the user has been blocked, the plugin reloads the comments.
Drop the handle for the signing key
The plugin drops the handle that represents the signing key of the user you just blocked.
DELETE /sign-key/:handleId
controller.js
window.safeSignKey.dropHandle(this._authToken, signKeyHandleId)
Last updated
Was this helpful?