Skip to content

fix(directory): #IMPULS-5881 add usefull link feature in directory - #1127

Merged
vbillard91 merged 4 commits into
develop-b2schoolfrom
feat-IMPULS-5881-usefull-link-feature
Sep 8, 2026
Merged

vbillard91 merged 4 commits into
develop-b2schoolfrom
feat-IMPULS-5881-usefull-link-feature

Conversation

@vbillard91

@vbillard91 vbillard91 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

add usefull link functionnality, add endpoints in directory and configuration to manage directory schema in postgresql

Fixes

https://edifice-community.atlassian.net/browse/IMPULS-5881

Type of change

Please check options that are relevant.

  • Chore (PATCH)
  • Doc (PATCH)
  • Bug fix (PATCH)
  • New feature (MINOR)

Which packages changed?

Please check the name of the package you changed

  • admin
  • app-registry
  • archive
  • auth
  • cas
  • common
  • communication
  • conversation
  • directory
  • feeder
  • infra
  • portal
  • session
  • test
  • tests
  • timeline
  • workspace

Tests

  1. Describe here the tests you performed
  2. Step by step
  3. With expected results

Reminder

  • Security flaws

  • Performance impacts (think bulk !)

  • Unit tests were replayed

  • Unit tests were added and/or changed

  • I have updated the reminder for the version including my modifications

  • All done ! 😃

@vbillard91
vbillard91 requested review from jcbe-ode and pb-jo September 2, 2026 15:15
Comment thread directory/src/main/java/org/entcore/directory/controllers/UserLinkController.java Outdated
private Sql sql = Sql.getInstance();

@Override
public Future<LinkOperationError> createLink(LinkDTO link, String userId) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Est-ce une bonne pratique d'utiliser des DTOs dans les signatures des méthodes des services ?
Le DTO en théorie est réservé à la [de]sérialization des données transférées.
Là, si on n'a pas de DTO , on ne peut pas appeler le service.

Pas vraiment bloquant, mais je me posais la question... 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci, la remarque m'a fait corriger deux choses.

pour le `deleteLink, le contrôleur n'a qu'un id de path param et devait
fabriquer un LinkDTO aux deux tiers vide . C'est devenu deleteLink(UUID linkId, String userId)

Il y un problème, côté retour. LinkOperationError transportait des codes HTTP (200/409/400) depuis le service, et un lien introuvable était un Future réussi portant 400. Remplacé par (CreateLinkResult, DeleteLinkResult)

En revanche je garde createLink(LinkDTO link, String userId). L'alternative createLink(String name, String url, String userId) donne
deux String adjacents interchangeables et l'autre solution est un type de domaine à côté du DTO, pour trois champs sans comportement, c'est une classe de plus, et une conversion pour reproduire les mêmes champs.
Le fait de ne pas avoir cette DTO n'est pas un problème, le service appartient à directory donc tu as forcement la DTO, tu peux appeler en HTTP sans DTO. Une DTO n'est pas réservé à la desiralization / ser des données, mais au transport. Si tu prends Wikipedia Un DTO (Data Transfer Object, ou objet de transfert de données en français) est un patron de conception (design pattern) utilisé en programmation pour transporter des données entre différentes couches ou sous-systèmes d'une application. Reste l'argument de la séparation des couches, dans notre stack technique sans contrat, je ne le trouve pas rentable ou pertinent

sql.prepared(" INSERT INTO directory.user_link(id, user_id, name, url, \"position\") " +
" SELECT ?::UUID, ?, ?, ?, free.pos " +
" FROM (SELECT s AS pos " +
" FROM generate_series(0, " + (MAX_LINKS_PER_USER - 1) + ") AS s " +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate_series : je ne connaissais pas

@jcbe-ode jcbe-ode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2-3 questions + il manque l'opération Update.
Pourrait être nécessaire un jour.

@Override
public Future<List<LinkDTO>> getLinks(String userId) {
Promise<List<LinkDTO>> promise = Promise.promise();
sql.prepared("SELECT id, user_id, name, url FROM directory.user_link WHERE user_id = ? ORDER BY lower(name) ASC NULLS LAST, id",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi ne pas trier par position plutôt ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'ailleurs, on ne peut pas réordonner les links entre eux ?
Il semble manquer le U de CRUD

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour le tri c'est au fonctionnel de dire ce qu'il veut comme tri. Pour l'update, c'est une bonne question, je vais rajouter le verbe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

CONSTRAINT user_link_user_position_key UNIQUE ("user_id", "position")
);

COMMENT ON COLUMN directory.user_link."position" IS 'Index de capacite, pas un ordre d''affichage : le CHECK 0..9 et la contrainte UNIQUE (user_id, position) sont ce qui plafonne un utilisateur a 10 liens. L''affichage est trie alphabetiquement sur name.';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voilà l'explication !

@vbillard91
vbillard91 force-pushed the feat-IMPULS-5881-usefull-link-feature branch from 86f1cdb to 13e84e0 Compare September 4, 2026 14:31
@vbillard91
vbillard91 requested a review from jcbe-ode September 7, 2026 08:32
@vbillard91
vbillard91 force-pushed the feat-IMPULS-5881-usefull-link-feature branch from 6acc7ad to 98f223b Compare September 7, 2026 13:58
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@vbillard91
vbillard91 merged commit 3db7bb0 into develop-b2school Sep 8, 2026
1 check passed
@vbillard91
vbillard91 deleted the feat-IMPULS-5881-usefull-link-feature branch September 8, 2026 08:15
pascalsaussier-edifice pushed a commit that referenced this pull request Sep 14, 2026
…1127)

* fix(directory): #IMPULS-5881 add usefull link feature in directory

* PR review

* PR review

* add update link endpoint
pascalsaussier-edifice added a commit that referenced this pull request Sep 14, 2026
…uvelle page d'accueil (#1132)

* fix(directory): #IMPULS-5881 add usefull link feature in directory (#1127)

* fix(directory): #IMPULS-5881 add usefull link feature in directory

* PR review

* PR review

* add update link endpoint

* feat(timeline): #IMPULS-6168 affiche le widget Liens utiles sur la nouvelle page d'accueil

Le widget (UsefulLinksContainer) vient de @edifice.io/react/homepage.
La disposition en 2 colonnes de la zone "moreWidgets" sera traitée dans
un ticket suivant.

---------

Co-authored-by: vbillard91 <vincent.billard@edifice.io>
vbillard91 added a commit that referenced this pull request Sep 16, 2026
…uvelle page d'accueil (#1132)

* fix(directory): #IMPULS-5881 add usefull link feature in directory (#1127)

* fix(directory): #IMPULS-5881 add usefull link feature in directory

* PR review

* PR review

* add update link endpoint

* feat(timeline): #IMPULS-6168 affiche le widget Liens utiles sur la nouvelle page d'accueil

Le widget (UsefulLinksContainer) vient de @edifice.io/react/homepage.
La disposition en 2 colonnes de la zone "moreWidgets" sera traitée dans
un ticket suivant.

---------

Co-authored-by: vbillard91 <vincent.billard@edifice.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants