Skip to main content

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)

info

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

NameTypeRequiredDescriptionDefault
itemIdstringyesA reported item id
itemTypestringnoThe reported item type 'user, post, comment, ...
reportedUserIdstringyesThe user you want to report is
deeplinkobjectyesCustom object that will be sent when navigating to the plugin
allowReportOverridebooleannoAllow override report and update it for same itemId and itemTypefalse

callback(err, result)

Callback function after the report function is completed.

NameTypeDescription
errobjectError object
resultobjectThe 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

NameTypeRequiredDescriptionDefault
itemIdstringnoA reported item id
itemTypestringnoA reported item id
pagenumbernoPage you want to retrieve0
pageSizenumbernoNumber of records per page, the max value is 50.50

callback(err, result)

Callback function after the get report is completed.

NameTypeDescription
errobjectError 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

NameTypeDescription
eventobjectObject sent by CP where the owner took action

allowMultipleHandlers

NameTypeRequiredDescriptionDefault
allowMultipleHandlersbooleannoTells 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

NameTypeDescription
reportIdstringThe report ID of the action taken