Module: DiasporaFederation::Federation::DiasporaUrlParser

Includes:
Logging
Defined in:
lib/diaspora_federation/federation/diaspora_url_parser.rb

Overview

This module is for parsing and fetching linked entities.

Constant Summary collapse

DIASPORA_URL_REGEX =

Regex to find diaspora:// URLs

%r{
  (?:web\+)?diaspora://
  (#{Validation::Rule::DiasporaId::DIASPORA_ID_REGEX})/
  (#{Entity::ENTITY_NAME_REGEX})/
  (#{Validation::Rule::Guid::VALID_CHARS})
}ux.freeze

Class Method Summary collapse

Methods included from Logging

included

Class Method Details

.fetch_linked_entities(text) ⇒ Object

Parses all diaspora:// URLs from the text and fetches the entities from the remote server if needed.

Parameters:

  • sender (String)

    the diaspora* ID of the sender of the entity

  • text (String)

    text with diaspora:// URLs to fetch



21
22
23
24
25
# File 'lib/diaspora_federation/federation/diaspora_url_parser.rb', line 21

def self.fetch_linked_entities(text)
  text.scan(DIASPORA_URL_REGEX).each do |author, type, guid|
    fetch_entity(author, type, guid)
  end
end