To get the current post, in the context of the button click, use the data-pid selector.
var pid = $(this).closest('[data-pid]').data('pid');
Now for the current user, you would submit a socket or route call with your pid, and check server-side.
For sockets, you get socket.uid https://github.com/NodeBB/NodeBB/blob/8ea5c060f50d1231c3ae3f7cbf5b2fe23ecf51e6/src/socket.io/notifications.js#L10
For routes, you get req.uid https://github.com/NodeBB/NodeBB/blob/54c951cc816b83168083000ae3e08af6c07d4c73/src/controllers/user.js#L12