Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-11349

Mini message gadget hides messages from "computed" members of the social workspace

    XMLWordPrintable

    Details

      Description

      When using a social workspace, the mini messages gadget only display messages by explicit members of the group: it uses the MiniMessageActivityStreamFilter with query type MINI_MESSAGES_FOR_ACTOR, and fetches the social workspace members with relationshipService.getTargetsOfKind().

      This becomes a problem when members are set through a GroupComputer rather than added manually. In that case, all "computed" members cannot post mini-messages (they are correctly saved, but not displayed).

      So why make the mini messages query based on a user whitelist? It feels unnecessary since the context parameter already does the needed filtering ; plus the query can become quite heavy if the social workspace has a lot of members. The only thing we lose by removing the whitelist is that it would no longer hide messages from users that left the space, but it doesn't feel like an issue to me.

      I resolved this by overriding the MiniMessageActivityStreamFilter:

         .....
              case MINI_MESSAGES_FOR_ACTOR:
                  if (actor == null) {
                      throw new IllegalArgumentException(ACTOR_PARAMETER
                              + " is required");
                  }
      
                  if (actor.equals(context)) {
                      // FIX: Do not use an actor constraint, to include mini-messages from virtual members
                      query = em.createQuery("select activity from Activity activity where activity.verb = :verb " +
                              "and (activity.context = :context or activity.target = :target) " +
                              "order by activity.publishedDate desc");
                  }
                  else {
                       RelationshipKind relationshipKind = (RelationshipKind) parameters.get(RELATIONSHIP_KIND_PARAMETER);
                       RelationshipService relationshipService = Framework.getLocalService(RelationshipService.class);
                       List<String> actors = relationshipService.getTargetsOfKind(actor, relationshipKind);
                       actors.add(actor);
                       
                       StringBuilder sb = new StringBuilder(
                               "select activity from Activity activity where activity.actor in (:actors) and activity.verb = :verb ");
                       if (context != null) {
                           sb.append("and (activity.context = :context or activity.target = :target) ");
                       } else {
                           sb.append("and activity.context is null and activity.target is null ");
                       }
                       sb.append("order by activity.publishedDate desc");
                       query = em.createQuery(sb.toString());
                       query.setParameter("actors", actors);
                  }
                  
                  query.setParameter("verb", VERB);
                  if (context != null) {
                      query.setParameter("context", context);
                      query.setParameter("target", context);
                  }
                  
                  break;
      

      An actual patch would probably add instead a new query type MINI_MESSAGES_FOR_CONTEXT I guess, and plug it to the minimessages gadget.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: