assemblee-virtuelle / semapps

A toolbox to create semantic web applications
https://semapps.org
Apache License 2.0
87 stars 8 forks source link

Refactor ActivitiesHandlerMixin #1230

Open srosset81 opened 9 months ago

srosset81 commented 9 months ago

Problem

Right now, for every service using the ActivitiesHandlerMixin, a matching is made for all activities received or sent. The more services are doing this, the worst the performance become.

Solution

Create a ActivitiesWatcherService which is activated by default with the ActivityPub service.

This service as a watch action which takes a matcher (object or function), an actionName and a key.

On start, the ActivitiesHandlerMixin calls the watch function for all defined activities. The actionName is a processActivity action of this mixin.

The process action receives a key, a boxType (inbox/outbox), a dereferencedActivity and actorUri.

It thens calls the onEmit and onReceive methods of the corresponding activity.

srosset81 commented 9 months ago

Ideas:

srosset81 commented 7 months ago

Done here #1240 but performances could be improved