Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Getting string length in Confluence Email Notification Soy Template

Ken D: Uemura January 12, 2016

Hi,

We are trying to remove the $content from notification email if it exceeds 25MB ( or maybe a lot less, 5MB ), since Gmail SMTP doesn't accept email larger than 25MB, and yes some of our users are creating a page bigger than 25MB when it renders using multiple SQL macros... 

In templates/chrome/main-table-1.0.0.soy from confluence-email-notifications-plugin, we've tried modifying the if statement but it didn't work..

{if $content and strLen($content) < 5000000}
    <tr>
        <td {if $pattern.id}id="{$pattern.id}" {/if}class="email-content-main mobile-expand{if $pattern.class} {$pattern.class}{/if}{if isLast($pattern)} last-row-padding{/if}">
            {$content|noAutoescape}
        </td>
    </tr>
{else}
    <tr>
        <td {if $pattern.id}id="{$pattern.id}" {/if}class="email-content-main mobile-expand{if $pattern.class} {$pattern.class}{/if}{if isLast($pattern)} last-row-padding{/if}">
            Content too large, visit page to see the content.
        </td>
    </tr>
{/if}

I saw strLen function listed in https://bitbucket.org/atlassian/atlassian-soy-templates/src/a2c124d7a22a52fd28c3d2ec4475529d161d139b/core/src/main/java/com/atlassian/soy/impl/modules/CustomFunctionsModule.java?at=master&fileviewer=file-view-default, so I thought it might would work.

 

We've also tried following too but didn't work either..

 

Please suggest any method of achieving this, or documentation on available functions for getting the string length.

 

Thanks,

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2016

Can't really help with the logging issue unfortunately. I'd suggest raising a Bug in jira.atlassian.com/browse/CONF - I would think it should log email errors. You might also want to try explicitly looking at the mail logs to see if it's been logged there instead. Best of luck!

0 votes
Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2016

It's worth noting that the strLen function isn't listed on the Closure Template docs - https://developers.google.com/closure/templates/docs/functions

I'm not sure whether it's actually available or not (it would seem not). Confluence may also be using an older version of the Soy plugin (and of Closure Templates themselves).

You can create your own Soy functions using an Atlassian plugin. Note that these functions will be globally available, so you should prefix them with your company name. You define them by extending SoyServerFunction (or SoyClientFunction to support JS contexts) and register them in your atlassian-plugin.xml with a module like:

<soy-function key="mycompany-strlen-soy-function" class="com.myCompany.StrLen"/>

Hope that helps!

Adam

Ken D: Uemura January 12, 2016

Thanks Adam, we will try that! Ken

0 votes
BroadcomS January 12, 2016

Hello I am working on this as well along Ken. When we try any of the paths that "didn't work" we don't get any notification email sent by Confluence but we also don't get any log information regarding what kind of error was thrown. This is how we try to print strLen: {code} <br />StrLen: {strLen($content)}<br /> {code} I can also see there are custom soy functions inside the confluence-email-notifications-plugin-6.4.0.jar that we have tested successfully but none of them returns a String's length. Is there a way for us to create this new function and add it to the jar? Or can you provide us with a way to get the lenght of any String from within the .soy files in the jar? Thanx Luis

0 votes
Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2016

Can you define "didn't work" please? You might be able to get more information also by printing the strLen into the template.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events