public async Task <IActionResult> OnUnsubscribe([FromBody] OnUnsubscribePayload request) { var result = await Unsubscribe(request); if (result != null && result is OkOnUnsubscribeResult authResult) { return(Ok(new { Result = "ok", authResult.Topics })); } return(result.GeneratePublicResult()); }
/// <summary> /// This method is called when client is trying to unsubscribe specific topics. You can accept or reject the client to unsubscription. /// To accept client request return complex <see cref="OkOnUnsubscribeResult"/> to rewrite topics or simple <see cref="OkResult"/>. /// To ingore client request return <see cref="NextResult"/> /// To reject client request return <see cref="ErrorResult"/> /// For more information <see cref="https://docs.vernemq.com/plugin-development/subscribeflow#on_unsubscribe-and-on_unsubscribe_m5"/> /// </summary> /// <param name="authOnRegisterPayload"></param> /// <returns>return value must be one of <see cref="OkResult"/> or <see cref="OkOnUnsubscribeResult"/> or <see cref="NextResult"/> or <see cref="ErrorResult"/> </returns> protected virtual async Task <HookResult> Unsubscribe(OnUnsubscribePayload onUnsubscribePayload) { return(new OkResult()); }