Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
bogdan
/
offer_share.rb
Last active
Nov 17, 2017
Star
1
Fork
0
Star
Code
Revisions
5
Stars
1
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Raw
offer_share.rb
# Our architecture didn't allow us
# to customize message body in a right way.
# That is why we fuck it up right here.
def
fuck_short_url
(
text
)
return
nil
unless
text
# Offer short url in email should differ from generic one
# Additional parameters should be included:
# share_specific_short_url includes {source: 'email', email_shared_with: email}
# Sometimes we can not avoid this hack because of the following usecase:
# When user is sharing offer via email though talkable offer page
# Email body might have a link within.
# For example user sees the following message body:
# "I can get you $25 off with this link: http://www.talkable.com/x/Uk6EX"
# In "Share this offer by email" form
# But this link doesn't yet know the email person wants to share with.
# And we are not able to set a placeholder
# That is why we need this hack to replace it.
whitelist
=
[
site
.
url
,
site
.
custom_domain
]
.
compact
text
.
gsub
(
URI
.
regexp
(
[
'http'
,
'https'
]
)
)
do
|
url
|
whitelist
.
include?
(
url
)
?
url
:
self
.
share_specific_short_url
end
end
This comment has been minimized.
Sign in to view
Copy link
Quote reply
vanclist
commented
Nov 17, 2017
Typo:
though
->
through
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
This comment has been minimized.
Typo:
though
->through