Module: MMS2R::Media::Sprint

Defined in:
lib/mms2r/media/sprint.rb

Overview

Sprint version of MMS2R::Media

Sprint is an annoying carrier because they don’t actually transmit user generated content (like images or videos) directly in the MMS message. Instead, they hijack the media that is sent from the cellular subscriber and place that content on a content server. In place of the media the recipient receives a HTML message with unsolicited Sprint advertising and links back to their content server. The recipient has to click through Sprint more pages to view the content.

The default subject on these messages from the carrier is “You have new Picture Mail!”

Instance Method Summary collapse

Instance Method Details

#processObject

Override process() because Sprint doesn’t attach media (images, video, etc.) to its MMS. Media such as images and videos are hosted on a Sprint content server. MMS2R::Media::Sprint has to pick apart an HTML attachment to find the URL to the media on Sprint’s content server and download each piece of content. Any text message part of the MMS if it exists is embedded in the html.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/mms2r/media/sprint.rb', line 38

def process
  unless @was_processed
    log("#{self.class} processing", :info)
    #sprint MMS are multipart
    parts = @mail.parts

    #find the payload html
    doc = nil
    parts.each do |p|
      next unless p.part_type? == 'text/html'
      d = Nokogiri(p.body.decoded)
      title = d.at('title').inner_html
      if title =~ /You have new Picture Mail!/
        doc = d
        @is_video = (p.body.decoded =~ /type="VIDEO">/m ? true : false)
      end
    end
    return if doc.nil? # it was a dud
    @is_video ||= false

    # break it down
    sprint_phone_number(doc)
    sprint_process_text(doc)
    sprint_process_media(doc)

    @was_processed = true
  end

  # when process acts upon a block
  if block_given?
    media.each do |k, v|
      yield(k, v)
    end
  end

end