Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jmduke committed Jan 4, 2025
1 parent 75fbc04 commit e28119c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions lib/postal/message_db/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def html_body
end

#
# Return the HTML body with any tracking links
# Return the HTML body with the tracking image removed.
#
def html_body_without_tracking_image
html_body.gsub(/<p class=['"]ampimg['"].*?<\/p>/, "")
Expand Down Expand Up @@ -573,8 +573,15 @@ def parsed?
# Should this message be parsed?
#
def should_parse?
# Header values are always arrays, so we check for `['skip']` instead of `'skip'`
parsed? == false && headers["x-amp"] != ["skip"]
parsed? == false
end

def track_clicks?
headers["x-track-clicks"] != ["no"]
end

def track_loads?
headers["x-track-opens"] != ["no"]
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/postal/message_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def parse_parts(parts)
end

def parse(part, type = nil)
if @domain.track_clicks?
if @domain.track_clicks? && @message.track_clicks?
part = insert_links(part, type)
end

if @domain.track_loads? && type == :html
if @domain.track_loads? && @message.track_loads? && type == :html
part = insert_tracking_image(part)
end

Expand Down

0 comments on commit e28119c

Please sign in to comment.