Class: Async::Matrix::DoublePuppetClient

Inherits:
Client
  • Object
show all
Defined in:
lib/async/matrix/double_puppet_client.rb

Overview

A Client subclass that authenticates with a user’s double puppet token instead of the appservice’s as_token.

This allows the bridge to send events as the real Matrix user rather than as the appservice bot or a ghost user.

puppet = DoublePuppetClient.new(config, double_puppet_token: "syt_...")
puppet.send_text("!room:example.com", "sent as the real user")
puppet.whoami  # => {"user_id" => "@alice:example.com"}

Constant Summary

Constants inherited from Client

Client::CLIENT_PREFIX, Client::DEFAULT_ERROR_RESPONSE_SIZE_LIMIT, Client::DEFAULT_MAX_RETRIES, Client::DEFAULT_MAX_RETRY_DELAY, Client::DEFAULT_RESPONSE_SIZE_LIMIT, Client::DEFAULT_RETRY_BASE, Client::GATEWAY_ERROR_STATUSES, Client::RATE_LIMIT_STATUS

Instance Attribute Summary

Attributes inherited from Client

#config

Instance Method Summary collapse

Methods inherited from Client

#api, #close, #get, #join_room, #leave_room, #media, #media_client, #post, #put, #send_html, #send_message_event, #send_notice, #send_text, #set_display_name, #whoami

Constructor Details

#initialize(config, double_puppet_token:, **kwargs) ⇒ DoublePuppetClient

Returns a new instance of DoublePuppetClient.



22
23
24
25
# File 'lib/async/matrix/double_puppet_client.rb', line 22

def initialize(config, double_puppet_token:, **kwargs)
  super(config, **kwargs)
  @headers[0] = ["authorization", "Bearer #{double_puppet_token}"]
end