docs: async def invite(self, room_id: str, user_id: str, check_cache: bool = False
                       ) -> Optional[dict]:
          """
          Invite a user to participate in a particular room. See also: `API reference`_
  
          Args:
              room_id: The room identifier (not alias) to which to invite the user.
              user_id: The fully qualified user ID of the invitee.
              check_cache: Whether or not to check the state cache before inviting.
                  If true, the actual invite HTTP request will only be made if the user is not in the
                  room according to local state caches.
  
          Returns:
          .. _API reference:
             https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-createroom
          """
          await self.ensure_joined(room_id)
          try:
              ok_states = {"invite", "join"}
              do_invite = (not check_cache
                           or self.state_store.get_membership(room_id, user_id) not in ok_states)
              if do_invite:
                  response = await self._invite_direct(room_id, user_id)
                  self.state_store.invited(room_id, user_id)
                  return response
          except MatrixRequestError as e:
              if e.errcode != "M_FORBIDDEN":
                  raise IntentError(f"Failed to invite {user_id} to {room_id}", e)
              if "is already in the room" in e.message:
                  self.state_store.joined(room_id, user_id)