How to get the current_user details in Discourse.Dialect.postProcessText for both client and server side?

@cpradio Thanks for the clarification, I was actually using the old plugin interface to manipulate text in the editor.

I tried the new way as shown by @tgxworld, Unfortunately even that didn’t work. I ended up in the same situation. Here is the sample code

import { registerOption } from 'pretty-text/pretty-text';

registerOption((siteSettings, opts) => {
  opts.features["sensitive_content_masking"] = true;
});

function maskSensitiveContent(text, user){
 
  var result = text. //Performing my regex and masking

  if(user !== null && (user.admin === true || user.moderator === true)){
    return text;
  }else{
    return result;
  }
}

export function setup(helper){
  helper.addPreProcessor(text => {
    return maskSensitiveContent(text, helper.getOptions().currentUser);
  });
}

This works perfectly in the editor and I can see int the preview section that the content is getting masked.
But when I save this I am getting error Cannot read property 'admin' of undefined/nTypeError: of around this line

Seems like currentUser or not even the opts is available in the server side when it try to cook with the V8 context.