ExpandedVenture / ConnectionSphere

Simple Service to Start Prospecting Online
0 stars 0 forks source link

Responses screen failing when Embedded-Links is activated for the pipeline, but links in the message are not embedded links. #203

Open ExpandedVenture opened 2 years ago

ExpandedVenture commented 2 years ago

This is the piece of code failing:

./lib/prospecting/message.rb:74.

Error: Undefined client

  # replace links by embedded-links belinging the same client oner of the result.
  def self.apply_embedded_links(body, r)
    p = r.pipeline
    c = p.user.client
    return body if p.ats_tracking_mode.to_i != Pipeline::TRACKING_MODE_EMBEDDED_LINKS
    # If the body has links that matches with the URL of any embedded links belonging to the same client,
    # then replace the link by the embedded link.
    body.scan(BlackStack::Strings::MATCH_URL).map { 
      |url| url.join 
    }.each { |url|  
      e = client.embedded_links.select { |e| e.url == url }.first
      if !e.nil?
        body.gsub!(url, e.embedded_url)
      end # if
    }  
    body
  end