Forum Discussion

bhupen's avatar
bhupen
Advisor
10 years ago

Notification executing twice.


Hi guys,
I have a notification issue. The issue is notification executing twice everytime. When any of user mentioning me at any post its executing twice .i.e. some one mentioned you in post. Notification is coming twice instead of once. I assume its a rest error. Following is the code. If anybody suggest me what iam doing wrong that will be helpful.

<#assign _notificationsCount = restadmin( '/users/id/' + user.id + '/notifications/count' ).value?number />
<#if ( _notificationsCount > 999 )>    
                <#assign _notificationsCount = 999 />
                </#if>
                <#assign notifications       = [] />
                <#assign allowed             = [ 'kudos', 'mentions', 'solutions', 'badge', 'rank' ] />
                <#assign notificationsPage   = 1 />
                <#assign usedNotifications   = [] />        
                
                <#function getNotifications>
                <#assign page = notificationsPage * pageSize />
                <#assign nots = restadmin( '/users/id/' + user.id + '/notifications?restapi.response_style=view&page_size=' + page ).notifications />
            
                <#if ( nots?size > 0 )>
                    <#list nots.notification as notification>
                            <#if ( ( !usedNotifications?seq_contains( notification_index ) ) && ( allowed?seq_contains( notification.notification_type ) ) && ( notifications?size < pageSize ) )>
                            
                                <#assign notifications     = notifications + [notification]>
                                <#assign usedNotifications = usedNotifications + [notification_index]>
                                <#assign i = i + 1 />
                            </#if>
                        </#list>
                <#if ( (notifications?size < pageSize) && ( ( _notificationsCount - page ) > 0 ) && (notifications?size < i))>
                        <#assign notificationsPage = notificationsPage + 1 />                    
                            <#assign go = getNotifications() />                        
                        </#if>
                </#if>
                <#return 1 />
            </#function>

  • Hi guys,

     I found fix for this. Sharing it with you, in case you will face such kind issue. There was a default navigaton called on header navigation. I was just checking on community header instead of header section. Now I removed it and used custom notification I made.

    <component id="common.widget.user-navigation"/>

     

    Silly Mistake :)

4 Replies

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    10 years ago

    Hi bhupen 

     

    do you mean that your call in red returns the same notification multiple times? If so, please file it with Support as it does sound like a legitimate bug to me.

     

    Thanks,

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    bhupen isn't it 'as expected'?

     

    I'm not sure what your code do / where it's executed. But it could be that your code generates one notification.

    And the 'core' platform another one too ...

     

    I suppose that if you remove your code, you receive only one notification when user mentions you, no?

  • Hi guys,

     I found fix for this. Sharing it with you, in case you will face such kind issue. There was a default navigaton called on header navigation. I was just checking on community header instead of header section. Now I removed it and used custom notification I made.

    <component id="common.widget.user-navigation"/>

     

    Silly Mistake :)