Skip to content

Commit

Permalink
Merge pull request #2317 from liberapay/various
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco authored Feb 22, 2024
2 parents 8817f56 + 408f26e commit 0c98b05
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions emails/base.spt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $body
_("Something wrong? This email was sent automatically, but you can contact us by replying to it.")
}}</div>
<div style="font-size: 14px; padding-top: 12px;">
<a href="https://liberapay.com/about/me/emails/"
<a href="{{ participant.url('emails/') }}"
style="text-decoration: underline;">{{
_("Change your email settings")
}}</a>.
Expand All @@ -29,4 +29,4 @@ $body

{{ _("Something wrong? This email was sent automatically, but you can contact us by replying to it.") }}

{{ _("Change your email settings") }}: https://liberapay.com/about/me/emails/
{{ _("Change your email settings") }}: {{ participant.url('emails/') }}
3 changes: 0 additions & 3 deletions liberapay/models/account_elsewhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ def update():
raise

# Return account after propagating avatar_url to participant
avatar_url = account.avatar_url
if avatar_url and avatar_url.startswith('https://pbs.twimg.com/'):
avatar_url = 'https://nitter.net/pic/' + avatar_url[22:].replace('/', '%2F')
account.participant.update_avatar(check=False)
return account

Expand Down
11 changes: 3 additions & 8 deletions liberapay/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ def url(self, path='', query='', log_in='auto'):
extra_query = []
if log_in == 'required' or log_in == 'auto' and not self.has_password:
primary_email = self.get_email_address()
if email_row.address.lower() == primary_email.lower():
if primary_email and email_row.address.lower() == primary_email.lower():
# Only send login links to the primary email address
session = self._email_session
if not session:
Expand All @@ -1810,13 +1810,8 @@ def url(self, path='', query='', log_in='auto'):
extra_query.append(('log-in.token', session.secret))
if log_in != 'required':
extra_query.append(('log-in.required', 'no'))
else:
try:
raise AssertionError('%r != %r' % (email_row.address, primary_email))
except AssertionError as e:
website.tell_sentry(e)
if log_in == 'required':
raise
elif log_in == 'required':
raise AssertionError('%r != %r' % (email_row.address, primary_email))
if not email_row.verified:
if not email_row.nonce:
email_row = self._rendering_email_to = self.db.one("""
Expand Down
3 changes: 3 additions & 0 deletions sql/branch.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE participants
SET avatar_url = 'https://pbs.twimg.com/' || regexp_replace(substr(avatar_url, 24), '%2F', '/', 'g')
WHERE avatar_url LIKE 'https://nitter.net/pic/%';
2 changes: 2 additions & 0 deletions tests/py/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def test_email_login(self):
alice = self.make_participant('alice', email=None)
alice.add_email(email)
alice.close()
self.db.run("DELETE FROM user_secrets")

# Sanity checks
email_row = alice.get_email(email)
Expand Down Expand Up @@ -248,6 +249,7 @@ def test_email_login_with_old_unverified_address(self):
alice = self.make_participant('alice', email=None)
alice.add_email(email)
Participant.dequeue_emails()
self.db.run("DELETE FROM user_secrets")
self.db.run("UPDATE emails SET nonce = null")

# Initiate email log-in
Expand Down
7 changes: 5 additions & 2 deletions www/admin/payments.spt
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ title = "Payments Admin"

% extends "templates/layouts/admin.html"

% macro render_payin_transfer(pt, pi)
% macro render_payin_transfer(pt, pi, show_amount=True)
<li>
% if show_amount
{{ locale.format_money(pt.amount) }}
% endif
to <a href="/~{{ pt.recipient }}/">{{ pt.recipient_name }}</a>
% if pt.period
({{ locale.format_money(pt.unit_amount) }}/{{ pt.period[:-2] }} × {{ pt.n_units }})
Expand Down Expand Up @@ -167,8 +169,9 @@ title = "Payments Admin"
{{ locale.format_money_basket(item['sum']) }}
through team <a href="/~{{ item['team_id'] }}/">{{ item['team_name'] }}</a>
<ul class="hooked-right-pointing-arrows">
% set show_amount = len(item['transfers']) > 1
% for pt in item['transfers']
{{ render_payin_transfer(pt, pi) }}
{{ render_payin_transfer(pt, pi, show_amount=show_amount) }}
% endfor
</ul>
</li>
Expand Down
9 changes: 8 additions & 1 deletion www/callbacks/stripe.spt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ elif event_object_type == 'charge.dispute':
# Notify the person who initiated the payment
payer = Participant.from_id(payin.payer)
if dispute.status in ('needs_response', 'lost'):
try:
due_by = dispute.evidence_details.due_by
except AttributeError:
due_by = 0
try:
payer.notify(
'payin_disputed',
Expand All @@ -97,7 +101,10 @@ elif event_object_type == 'charge.dispute':
payin_amount=payin.amount,
payin_ctime=payin.ctime,
dispute_reason=dispute.reason,
dispute_can_be_withdrawn=dispute.status == 'needs_response',
dispute_can_be_withdrawn=(
dispute.status == 'needs_response' and
due_by > utcnow().timestamp()
),
mandate_url=route.get_mandate_url(),
)
except DuplicateNotification:
Expand Down

0 comments on commit 0c98b05

Please sign in to comment.