Fixed Push notifications ignore phrases in "push_post_reaction" and "push_conversation_message_reaction"

Aivaras

Well-known member
Affected version
2.1.3
Replacing the phrases:
  • x_reacted_to_your_post_in_the_thread_y
  • x_reacted_to_your_message_in_the_conversation_y
with other phrases in:
  • push_post_reaction
  • push_conversation_message_reaction
respectively, is not reflected in push notifications.

Doing the same thing in:
  • alert_post_reaction
  • alert_conversation_message_reaction
works as expected: phrase replacements are reflected in alerts.
 
This is because Push notifications do not switch from using master style, and thus don't pull templates from whatever is selected as the default style.
 
It isn't a bug.

A push template isn't expected to have any style specific elements because it should only output text, therefore we do not attempt to maintain the receiving user's style when rendering the push output.

It isn't really clear what you're trying to achieve, but it seems like you are editing the template in order to use a different phrase.

Why aren't you able to just edit the phrase? We do maintain the user's selected language.
 
The phrases in the push template are shared with the alert template. You can't change one without changing the other, and if you want a specific push message, you need to edit the alerts templates to use a different phrase then edit the stock phrase. Which feels rather backwards.
 
I'm dealing with a natural language very different from English. To make translation work grammatically I often have to resort to two or more custom phrases instead of the original single phrase. The replacement phrases are then wrapped in conditional statements connected to user custom fields.

The phrase replacement method works perfectly in all the cases except push notifications where I'm left with inconsistent behavior (alerts vs push notifications being one example thereof).

Pretty sad about this because having those push templates available the solution seems to be but an arm stretch away and yet I can't reach it.
because it should only output text
It is only about text output. And I can't get it right because of the master style limitation.
 
The phrases in the push template are shared with the alert template. You can't change one without changing the other, and if you want a specific push message, you need to edit the alerts templates to use a different phrase then edit the stock phrase. Which feels rather backwards.
But then wanting different messages for the same thing seems rather backwards, so 🤷‍♂️

Rather than just calling things "backwards" some context as to why such a thing is needed is much more useful. And it seems you actually have no insight into this particular use case anyway, so you're just not helping.
I'm dealing with a natural language very different from English. To make translation work grammatically I often have to resort to two or more custom phrases instead of the original single phrase. The replacement phrases are then wrapped in conditional statements connected to user custom fields.

The phrase replacement method works perfectly in all the cases except push notifications where I'm left with inconsistent behavior (alerts vs push notifications being one example thereof).

Pretty sad about this because having those push templates available the solution seems to be but an arm stretch away and yet I can't reach it.

It is only about text output. And I can't get it right because of the master style limitation.
Finally. A useful use case that we're able to make sense of.

To be clear though, I don't believe we're rendering from the master style. So if you're seeing different results, it indicates that you haven't made the same template edit in all styles.
 
The different results are in the same style. Technically, I don't know what causes the limitation. The method I described in the previous post works for all the other templates except the push ones.
 
To be clear though, I don't believe we're rendering from the master style. So if you're seeing different results, it indicates that you haven't made the same template edit in all styles.
Alerts/Push notifications sent in job.php via a service notifier use the master style, as the code path doesn't set the style so it is either master or whatever some other jobs sets it as. While alerts/push notifications sent after rendering likely have whatever the current user's style is.
 
Can you post the full changes you have made to the template?
An example of syntax that does not work:

Repace this:
HTML:
{{ phrase('x_reacted_to_your_post_in_the_thread_y', {
    'name': $user.username ?: $alert.username,
    'reaction': reaction_title($extra.reaction_id),
    'title': prefix('thread', $content.Thread, 'plain') . $content.Thread.title
}) }}
with:
HTML:
<xf:if is="$user.Profile.custom_fields.test == '1'">
    {{ phrase('x_reacted_to_your_post_in_the_thread_y_1', {
        'name': $user.username ?: $alert.username,
        'reaction': reaction_title($extra.reaction_id),
        'title': prefix('thread', $content.Thread, 'plain') . $content.Thread.title
    }) }}
<xf:elseif is="$user.Profile.custom_fields.test == '2'" />
    {{ phrase('x_reacted_to_your_post_in_the_thread_y_2', {
        'name': $user.username ?: $alert.username,
        'reaction': reaction_title($extra.reaction_id),
        'title': prefix('thread', $content.Thread, 'plain') . $content.Thread.title
    }) }}
<xf:else />
    {{ phrase('x_reacted_to_your_post_in_the_thread_y', {
        'name': $user.username ?: $alert.username,
        'reaction': reaction_title($extra.reaction_id),
        'title': prefix('thread', $content.Thread, 'plain') . $content.Thread.title
    }) }}
</xf:if>
in "push_post_reaction."
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.4).

Change log:
When rendering push templates, attempt to maintain the receiving user's style (or the site default).
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Back
Top Bottom