phoneboy
5 years agoDirector
API request to Approve/Deny request to join a Group Hub Doesn't Seem to Work
I'm writing a component that will automatically approve a request to join a closed Group Hub.
This will be included in the relevant page quilt and is intended to replicate the functionality of legacy Groups where a group was Open but you had to explicitly join it before you saw content.
Looking at the relevant API documentation, it seems like it would be a relatively straightforward thing to implement.
The component looks like the following:
<#import "khoros-user-utils.ftl" as userUtils />
<#if user.registered >
<#assign uid = user.id?c />
<#assign node = coreNode.id />
<#assign messagePostBody = {
"type": "membership_request",
"approve_request": true,
"user_id": uid
} />
<#assign url = "/nodes/grouphub:${node}/membership_requests" />
<#assign resp = restadmin("2.0",url,"PUT",messagePostBody) />
</#if>
The API always returns "Membership Request not found" even though there is definitely a membership request for the relevant user in the relevant Group Hub:
{
"status" : "success",
"message" : "",
"http_code" : 200,
"data" : {
"type" : "membership_requests",
"list_item_type" : "membership_request",
"size" : 1,
"items" : [ {
"type" : "membership_request",
"user" : {
"type" : "user",
"id" : "226",
"href" : "/users/226",
"view_href" : "/t5/user/viewprofilepage/user-id/226",
"login" : "Doug"
},
"request_to_join_date" : "2020-09-18T00:56:56.885+02:00"
} ]
},
"metadata" : { }
}
Is there a bug with the API call or am I calling it incorrectly?