Module: DiasporaFederation
- Extended by:
- Logging
- Defined in:
- lib/diaspora_federation.rb,
lib/diaspora_federation/entity.rb,
lib/diaspora_federation/salmon.rb,
lib/diaspora_federation/logging.rb,
lib/diaspora_federation/parsers.rb,
lib/diaspora_federation/version.rb,
lib/diaspora_federation/entities.rb,
lib/diaspora_federation/callbacks.rb,
lib/diaspora_federation/discovery.rb,
lib/diaspora_federation/federation.rb,
lib/diaspora_federation/salmon/aes.rb,
lib/diaspora_federation/validators.rb,
lib/diaspora_federation/http_client.rb,
lib/diaspora_federation/entities/like.rb,
lib/diaspora_federation/entities/poll.rb,
lib/diaspora_federation/entities/post.rb,
lib/diaspora_federation/entities/embed.rb,
lib/diaspora_federation/entities/event.rb,
lib/diaspora_federation/entities/photo.rb,
lib/diaspora_federation/properties_dsl.rb,
lib/diaspora_federation/entities/person.rb,
lib/diaspora_federation/discovery/h_card.rb,
lib/diaspora_federation/entities/comment.rb,
lib/diaspora_federation/entities/contact.rb,
lib/diaspora_federation/entities/message.rb,
lib/diaspora_federation/entities/profile.rb,
lib/diaspora_federation/entities/reshare.rb,
lib/diaspora_federation/entities/location.rb,
lib/diaspora_federation/entities/signable.rb,
lib/diaspora_federation/federation/sender.rb,
lib/diaspora_federation/salmon/exceptions.rb,
lib/diaspora_federation/entities/relayable.rb,
lib/diaspora_federation/federation/fetcher.rb,
lib/diaspora_federation/parsers/xml_parser.rb,
lib/diaspora_federation/discovery/discovery.rb,
lib/diaspora_federation/entities/retraction.rb,
lib/diaspora_federation/federation/receiver.rb,
lib/diaspora_federation/parsers/base_parser.rb,
lib/diaspora_federation/parsers/json_parser.rb,
lib/diaspora_federation/discovery/exceptions.rb,
lib/diaspora_federation/discovery/web_finger.rb,
lib/diaspora_federation/entities/poll_answer.rb,
lib/diaspora_federation/entities/conversation.rb,
lib/diaspora_federation/salmon/magic_envelope.rb,
lib/diaspora_federation/discovery/xrd_document.rb,
lib/diaspora_federation/entities/participation.rb,
lib/diaspora_federation/entities/related_entity.rb,
lib/diaspora_federation/entities/status_message.rb,
lib/diaspora_federation/entities/account_deletion.rb,
lib/diaspora_federation/validators/like_validator.rb,
lib/diaspora_federation/validators/poll_validator.rb,
lib/diaspora_federation/entities/account_migration.rb,
lib/diaspora_federation/federation/receiver/public.rb,
lib/diaspora_federation/validators/embed_validator.rb,
lib/diaspora_federation/validators/event_validator.rb,
lib/diaspora_federation/validators/photo_validator.rb,
lib/diaspora_federation/entities/poll_participation.rb,
lib/diaspora_federation/federation/receiver/private.rb,
lib/diaspora_federation/validators/h_card_validator.rb,
lib/diaspora_federation/validators/person_validator.rb,
lib/diaspora_federation/entities/event_participation.rb,
lib/diaspora_federation/parsers/relayable_xml_parser.rb,
lib/diaspora_federation/validators/comment_validator.rb,
lib/diaspora_federation/validators/contact_validator.rb,
lib/diaspora_federation/validators/message_validator.rb,
lib/diaspora_federation/validators/profile_validator.rb,
lib/diaspora_federation/validators/reshare_validator.rb,
lib/diaspora_federation/parsers/relayable_json_parser.rb,
lib/diaspora_federation/validators/location_validator.rb,
lib/diaspora_federation/federation/diaspora_url_parser.rb,
lib/diaspora_federation/federation/receiver/exceptions.rb,
lib/diaspora_federation/validators/relayable_validator.rb,
lib/diaspora_federation/federation/sender/hydra_wrapper.rb,
lib/diaspora_federation/salmon/encrypted_magic_envelope.rb,
lib/diaspora_federation/validators/retraction_validator.rb,
lib/diaspora_federation/validators/web_finger_validator.rb,
lib/diaspora_federation/validators/poll_answer_validator.rb,
lib/diaspora_federation/validators/conversation_validator.rb,
lib/diaspora_federation/validators/participation_validator.rb,
lib/diaspora_federation/entities/account_migration/signable.rb,
lib/diaspora_federation/validators/optional_aware_validator.rb,
lib/diaspora_federation/validators/related_entity_validator.rb,
lib/diaspora_federation/validators/status_message_validator.rb,
lib/diaspora_federation/federation/receiver/abstract_receiver.rb,
lib/diaspora_federation/validators/account_deletion_validator.rb,
lib/diaspora_federation/validators/account_migration_validator.rb,
lib/diaspora_federation/validators/poll_participation_validator.rb,
lib/diaspora_federation/validators/event_participation_validator.rb
Overview
diaspora* federation library
Defined Under Namespace
Modules: Discovery, Entities, Federation, Logging, Parsers, PropertiesDSL, Salmon, Validators Classes: Callbacks, ConfigurationError, Entity, HttpClient
Constant Summary collapse
- VERSION =
the gem version
"1.1.0"
Class Attribute Summary collapse
-
.callbacks ⇒ Callbacks
readonly
Callbacks instance with defined callbacks.
-
.certificate_authorities ⇒ Object
Set the bundle of certificate authorities (CA) certificates.
-
.http_concurrency ⇒ Object
Maximum number of parallel HTTP requests made to other pods (default:
20
). -
.http_redirect_limit ⇒ Integer
readonly
Max redirects to follow.
-
.http_timeout ⇒ Object
Timeout in seconds for http-requests (default:
30
). -
.http_user_agent ⇒ String
readonly
User agent used for http-requests.
-
.http_verbose ⇒ Object
Turn on extra verbose output when sending stuff.
-
.server_uri ⇒ Object
The pod url.
-
.webfinger_http_fallback ⇒ Object
Configure if WebFinger discovery should fallback to http if https fails (default:
false
).
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
Configure the federation library.
-
.define_callbacks(&block) ⇒ Object
Define the callbacks.
-
.validate_config ⇒ Object
Validates if the engine is configured correctly.
Methods included from Logging
Class Attribute Details
.callbacks ⇒ Callbacks (readonly)
Callbacks instance with defined callbacks
56 57 58 |
# File 'lib/diaspora_federation.rb', line 56 def callbacks @callbacks end |
.certificate_authorities ⇒ String .certificate_authorities= ⇒ Object
Set the bundle of certificate authorities (CA) certificates
78 79 80 |
# File 'lib/diaspora_federation.rb', line 78 def @certificate_authorities end |
.http_concurrency ⇒ Integer .http_concurrency= ⇒ Object
Maximum number of parallel HTTP requests made to other pods (default: 20
)
103 104 105 |
# File 'lib/diaspora_federation.rb', line 103 def http_concurrency @http_concurrency end |
.http_redirect_limit ⇒ Integer (readonly)
Max redirects to follow
125 126 127 |
# File 'lib/diaspora_federation.rb', line 125 def http_redirect_limit @http_redirect_limit end |
.http_timeout ⇒ Integer .http_timeout= ⇒ Object
Timeout in seconds for http-requests (default: 30
)
111 112 113 |
# File 'lib/diaspora_federation.rb', line 111 def http_timeout @http_timeout end |
.http_user_agent ⇒ String (readonly)
User agent used for http-requests
129 130 131 |
# File 'lib/diaspora_federation.rb', line 129 def http_user_agent @http_user_agent end |
.http_verbose ⇒ Boolean .http_verbose= ⇒ Object
Turn on extra verbose output when sending stuff. (default: false
)
121 122 123 |
# File 'lib/diaspora_federation.rb', line 121 def http_verbose @http_verbose end |
.server_uri ⇒ URI .server_uri= ⇒ Object
The pod url
68 69 70 |
# File 'lib/diaspora_federation.rb', line 68 def server_uri @server_uri end |
.webfinger_http_fallback ⇒ Boolean .webfinger_http_fallback= ⇒ Object
Configure if WebFinger discovery should fallback to http if https fails (default: false
)
This is useful for example for development environments where https isn’t available.
This setting only applies to the WebFinger route from RFC 7033 /.well-known/webfinger
. Legacy WebFinger flow unconditionally falls back to http.
93 94 95 |
# File 'lib/diaspora_federation.rb', line 93 def webfinger_http_fallback @webfinger_http_fallback end |
Class Method Details
.configure {|_self| ... } ⇒ Object
Configure the federation library
141 142 143 |
# File 'lib/diaspora_federation.rb', line 141 def configure yield self end |
.define_callbacks(&block) ⇒ Object
Define the callbacks
In order to communicate with the application which uses the diaspora_federation gem callbacks are introduced. The callbacks are used for getting required data from the application or posting data to the application.
Callbacks are implemented at the application side and must follow these specifications:
fetch_person_for_webfinger
Fetches person data from the application to form a WebFinger reply
@param [String] diaspora* ID of the person
@return [DiasporaFederation::Discovery::WebFinger] person webfinger data
fetch_person_for_hcard
Fetches person data from the application to reply for an HCard query
@param [String] guid of the person
@return [DiasporaFederation::Discovery::HCard] person hcard data
save_person_after_webfinger
After the gem had made a person discovery using WebFinger it calls this callback
so the application saves the person data
@param [DiasporaFederation::Entities::Person] person data
fetch_private_key
Fetches a private key of a person by her diaspora* ID from the application
@param [String] diaspora* ID of the person
@return [OpenSSL::PKey::RSA] key
fetch_public_key
Fetches a public key of a person by her diaspora* ID from the application
@param [String] diaspora* ID of the person
@return [OpenSSL::PKey::RSA] key
fetch_related_entity
Fetches a related entity by a given guid
@param [String] entity_type (Post, Comment, Like, etc)
@param [String] guid of the entity
@return [DiasporaFederation::Entities::RelatedEntity] related entity
queue_public_receive
Queue a public salmon xml to process in background
@param [String] data salmon slap xml or magic envelope xml
queue_private_receive
Queue a private salmon xml to process in background
@param [String] guid guid of the receiver person
@param [String] data salmon slap xml or encrypted magic envelope json
@return [Boolean] true if successful, false if the user was not found
receive_entity
After the xml was parsed and processed the gem calls this callback to persist the entity
@param [DiasporaFederation::Entity] entity the received entity after processing
@param [Object] recipient_id identifier for the recipient of private messages or nil for public,
see {Receiver.receive_private}
fetch_public_entity
Fetch a public entity from the database
@param [String] entity_type (Post, StatusMessage, etc)
@param [String] guid the guid of the entity
fetch_person_url_to
Fetch the url to path for a person
@param [String] diaspora_id
@param [String] path
update_pod
Update the pod status
@param [String] url the pod url
@param [Symbol, Integer] status the error as {Symbol} or the http-status as {Integer} if it was :ok
225 226 227 |
# File 'lib/diaspora_federation.rb', line 225 def define_callbacks(&block) @callbacks.instance_eval(&block) end |
.validate_config ⇒ Object
Validates if the engine is configured correctly
called from after_initialize
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/diaspora_federation.rb', line 233 def validate_config configuration_error "server_uri: Missing or invalid" unless @server_uri.respond_to? :host unless defined?(::Rails) && !::Rails.env.production? configuration_error "certificate_authorities: Not configured" if @certificate_authorities.nil? unless File.file? @certificate_authorities configuration_error "certificate_authorities: File not found: #{@certificate_authorities}" end end validate_http_config unless @callbacks.definition_complete? configuration_error "Missing handlers for #{@callbacks.missing_handlers.join(', ')}" end logger.info "successfully configured the federation library" end |