Fix Question
display
Pleroma does not set the `endTime` field as Mastodon does.
This commit is contained in:
parent
42bf96e44a
commit
1189910b53
3 changed files with 11 additions and 7 deletions
7
app.py
7
app.py
|
@ -391,7 +391,7 @@ def gt_ts(val):
|
||||||
def format_timeago(val):
|
def format_timeago(val):
|
||||||
if val:
|
if val:
|
||||||
dt = parser.parse(val)
|
dt = parser.parse(val)
|
||||||
return timeago.format(dt, datetime.now(timezone.utc))
|
return timeago.format(dt.astimezone(timezone.utc), datetime.now(timezone.utc))
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
@ -405,7 +405,9 @@ def has_type(doc, _types):
|
||||||
|
|
||||||
@app.template_filter()
|
@app.template_filter()
|
||||||
def has_actor_type(doc):
|
def has_actor_type(doc):
|
||||||
for t in ap.ACTOR_TYPES:
|
# FIXME(tsileo): skipping the last one "Question", cause Mastodon sends question restuls as an update coming from
|
||||||
|
# the question... Does Pleroma do that too?
|
||||||
|
for t in ap.ACTOR_TYPES[:-1]:
|
||||||
if has_type(doc, t.value):
|
if has_type(doc, t.value):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -2184,6 +2186,7 @@ def _get_prop(props, name, default=None):
|
||||||
|
|
||||||
|
|
||||||
def get_client_id_data(url):
|
def get_client_id_data(url):
|
||||||
|
# FIXME(tsileo): ensure not localhost via `little_boxes.urlutils.is_url_valid`
|
||||||
data = mf2py.parse(url=url)
|
data = mf2py.parse(url=url)
|
||||||
for item in data["items"]:
|
for item in data["items"]:
|
||||||
if "h-x-app" in item["type"] or "h-app" in item["type"]:
|
if "h-x-app" in item["type"] or "h-app" in item["type"]:
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
{{ utils.display_actor_inline(data, size=80) }}
|
{{ utils.display_actor_inline(data, size=80) }}
|
||||||
{% elif data | has_type('Create') %}
|
{% elif data | has_type('Create') %}
|
||||||
{{ utils.display_note(data.object, ui=True) }}
|
{{ utils.display_note(data.object, ui=True) }}
|
||||||
{% elif data | has_type(['Note', 'Article', 'Video', 'Audio', 'Page']) %}
|
{% elif data | has_type(['Note', 'Article', 'Video', 'Audio', 'Page', 'Question']) %}
|
||||||
{{ utils.display_note(data, ui=True) }}
|
{{ utils.display_note(data, ui=True) }}
|
||||||
{% elif data | has_type('Announce') %}
|
{% elif data | has_type('Announce') %}
|
||||||
{% set boost_actor = meta.actor %}
|
{% set boost_actor = meta.actor %}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
{% set aid = obj.id | quote_plus %}
|
{% set aid = obj.id | quote_plus %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% set real_end_time = obj.closed or obj.endTime %}
|
||||||
|
|
||||||
<div class="note-box">
|
<div class="note-box">
|
||||||
<div class="note h-entry" id="activity-{{ obj.id | permalink_id }}">
|
<div class="note h-entry" id="activity-{{ obj.id | permalink_id }}">
|
||||||
|
@ -95,7 +96,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<p><small>
|
<p><small>
|
||||||
{% if obj.closed or obj.endTime | gtnow %}
|
{% if real_end_time | gtnow %}
|
||||||
Ended {{ obj.endTime | format_timeago }} with <strong>{{ total_votes }}</strong> vote{% if total_votes | gtone %}s{% endif %}.
|
Ended {{ obj.endTime | format_timeago }} with <strong>{{ total_votes }}</strong> vote{% if total_votes | gtone %}s{% endif %}.
|
||||||
{% else %}
|
{% else %}
|
||||||
Ends {{ obj.endTime | format_timeago }} (<strong>{{ total_votes }}</strong> vote{% if total_votes | gtone %}s{% endif %} as of now).
|
Ends {{ obj.endTime | format_timeago }} (<strong>{{ total_votes }}</strong> vote{% if total_votes | gtone %}s{% endif %} as of now).
|
||||||
|
@ -108,7 +109,7 @@
|
||||||
<li class="answer">
|
<li class="answer">
|
||||||
<span class="answer-text">
|
<span class="answer-text">
|
||||||
|
|
||||||
{% if not meta.voted_for and not obj.endTime | gtnow %}
|
{% if not meta.voted_for and not real_end_time | gtnow %}
|
||||||
<span><form action="/api/vote" class="action-form" method="POST">
|
<span><form action="/api/vote" class="action-form" method="POST">
|
||||||
<input type="hidden" name="redirect" value="{{ redir }}">
|
<input type="hidden" name="redirect" value="{{ redir }}">
|
||||||
<input type="hidden" name="id" value="{{ obj.id }}">
|
<input type="hidden" name="id" value="{{ obj.id }}">
|
||||||
|
@ -123,8 +124,8 @@
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<p><small>{% if obj.endTime | gtnow %}This question ended {{ obj.endTime | format_timeago }}.</small></p>
|
<p><small>{% if real_end_time | gtnow %}This question ended {{ real_end_time | format_timeago }}.</small></p>
|
||||||
{% else %}This question ends {{ obj.endTime | format_timeago }}{% endif %}
|
{% else %}This question ends {{ real_end_time | format_timeago }}{% endif %}
|
||||||
</small></p>
|
</small></p>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue