buildfire.services.reportAbuse
This service allows you to create report features for your plugins. On the other hand, the owner of the app can examine a list of every report of abuse for that app on the CP side.
Requirements
Widget
Include the reportAbuse.js
service and drawer.js
component files in the widget header right after the buildfire.min.js
<head>
// ...
<script src="../../../scripts/buildfire.min.js"></script>
<script src="../../../scripts/buildfire/components/drawer/drawer.js"></script>
<script src="../../../scripts/buildfire/services/reportAbuse/reportAbuse.js"></script>
</head>
Methods
report()
buildfire.services.reportAbuse.report(options, callback)
you can only submit one report per item
This function will be responsible for showing the abusers' drawer list and allowing note-writing. If the user is not already logged in, it will prompt them to do so.
buildfire.services.reportAbuse.report(
{
itemId: '12345',
reportedUserId: 'USER_ID',
deeplink: {
itemId: '12345',
},
itemType: "Post",
},
(err, result) => {
if (err) return console.error(err);
console.log("Report Data ", result);
}
);
params
Name | Type | Required | Description | Default |
---|---|---|---|---|
itemId | string | yes | A reported item id | |
itemType | string | no | The reported item type 'user, post, comment, ... | |
reportedUserId | string | yes | The user you want to report is | |
deeplink | object | yes | Custom object that will be sent when navigating to the plugin | |
allowReportOverride | boolean | no | Allow override report and update it for same itemId and itemType | false |
callback(err, result)
Callback function after the report function is completed.
Name | Type | Description |
---|---|---|
err | object | Error object |
result | object | The created abuse object |
getCurrentUserReports()
buildfire.services.reportAbuse.getCurrentUserReports(options, callback)
Use this method to search through multiple reports and retrieve a matching subset, required to see if this user has already reported the item.
buildfire.services.reportAbuse.getCurrentUserReports(
{
itemId: '12345',
itemType: 'Post'
},
(err, result) => {
if (err) return console.error(err);
console.log("Report Data ", result);
}
);
params
Name | Type | Required | Description | Default |
---|---|---|---|---|
itemId | string | no | A reported item id | |
itemType | string | no | A reported item id | |
page | number | no | Page you want to retrieve | 0 |
pageSize | number | no | Number of records per page, the max value is 50 . | 50 |
callback(err, result)
Callback function after the get report is completed.
Name | Type | Description |
---|---|---|
err | object | Error object |
result | [object] | Array of fetched abuses |
onAdminResponse()
buildfire.services.reportAbuse.onAdminResponse(callback, allowMultipleHandlers)
Override this call on the widget, to list for app owner event when he took the action for a reported item.
buildfire.services.reportAbuse.onAdminResponse((event) => {
console.log("onAdminResponse ", event);
});
event
Name | Type | Description |
---|---|---|
event | object | Object sent by CP where the owner took action |
allowMultipleHandlers
Name | Type | Required | Description | Default |
---|---|---|---|---|
allowMultipleHandlers | boolean | no | Tells the method to override all other handlers, or allow multiple handlers to exist at the same time. | false |
triggerWidgetReadyForAdminResponse()
buildfire.services.reportAbuse.triggerWidgetReadyForAdminResponse()
You should call this function after loading the widget and all necessary data because it notifies the cp that it is prepared to receive abuse actions.
buildfire.services.reportAbuse.triggerWidgetReadyForAdminResponse();
triggerOnAdminResponseHandled()
buildfire.services.reportAbuse.triggerOnAdminResponseHandled(message)
You should call this function after taking the action for Admin Response to confirm that the action has been taken
buildfire.services.reportAbuse.triggerOnAdminResponseHandled({
reportId: '55555'
});
message
Name | Type | Description |
---|---|---|
reportId | string | The report ID of the action taken |