pinMessage static method

Future<BaseMessage?> pinMessage(
  1. int messageId, {
  2. dynamic onSuccess(
    1. BaseMessage
    )?,
  3. dynamic onError(
    1. CometChatException excep
    )?,
})

Pin a message to its conversation.

Pins are conversation-global: every member sees the pin. Group pinning is permissioned server-side (admin/moderator/owner); 1-1 conversations allow both participants. The response — and onSuccess — carry the full updated message with pinnedAt/pinnedBy stamped. Idempotent: pinning an already-pinned message succeeds with the current state.

On the cap error ERR_PINNED_MESSAGES_LIMIT_EXCEEDED, the exception's errorParams map carries {"limit": <n>}.

Also fans out MessageListener.onMessagePinned locally on success so same-device surfaces update without waiting for the socket echo.

Implementation

static Future<BaseMessage?> pinMessage(int messageId,
    {Function(BaseMessage message)? onSuccess,
    Function(CometChatException e)? onError}) {
  return _pinSaveFacadeCall(
    messageId,
    'pinned',
    (sdk, id) => sdk.messages.pinMessage(id),
    onSuccess,
    onError,
  );
}