         if auth.canPinMessage(message) == .allowed {
             let pinMessage = message.pinned ? localized("chat.message.actions.unpin") : localized("chat.message.actions.pin")
             let pin = UIAlertAction(title: pinMessage, style: .default, handler: { (_) in
-                if message.pinned {
-                    MessageManager.unpin(message)
-                } else {
-                    MessageManager.pin(message)
-                }
+                client.pinMessage(message, pin: !message.pinned)
             })
 
             actions.append(pin)

            let isStarred = message.starred.contains(userId)
            let starMessage = isStarred ? localized("chat.message.actions.unstar") : localized("chat.message.actions.star")
            let star = UIAlertAction(title: starMessage, style: .default, handler: { (_) in
                API.current()?.client(MessagesClient.self).starMessage(message, star: !isStarred)
            })

            actions.append(star)

    func actionsForMessage(_ message: Message, view: UIView) -> [UIAlertAction] {
        guard
            let messageUser = message.user,
            let auth = AuthManager.isAuthenticated(),
            let client = API.current()?.client(MessagesClient.self)
        else {
            return []
        }
