Expand my Community achievements bar.

Custom Event Listener when you flag the comments getting called twice

Avatar

Level 3

Hi

We are using AEM 6.2 and Communities(FP2). We created the Custom Event class to capture the "flagging" event for comments to do our custom code.

But when I debug the code this class gets called two time and both the time the event action is "FLAG"

public class CustomSocialEventHandler implements ActivityStreamProviderExtension {

public boolean evaluate(final SocialEvent<?> evt, final Resource resource) {

if (evt.getAction() != null && evt.getAction() instanceof SocialEvent.SocialActions) {

....//Custom code

}

}

//Set the ranking as 5

@Override

    public int getRanking() {

        return 5;

    }

    @Override

    public String[] getStreamProviderPid() {

        return new String[]{"*"};

    }

}

Does internally two events get triggered when "Flag the Comment".

If any one has faced the same issue, any help is much appreciated.

Thanks,

Monika

2 Replies

Avatar

Level 10

This is strange - this event should only fire 1 time.

Avatar

Level 3

I tried it with OOB comments as well.(Tried on the we-retail website) When I flag or Delete the comment, on that it calls the custom event class which we wrote as I described above (In the sample code).

We followed the same  example given on this page

OSGi Events for Communities Components

So Use case for us was to "Add one property in the activitystream object of a comment" when comment gets deleted.

And we have some other custom code inside this class to send some alert emails, then only we realized that this class is getting called twice.

Not sure why in the backend these events are getting generated twice. Please let me know if you find something on that.