Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°7385 - Trigger on mention executed even if it's not a mention with @ #638

Open
wants to merge 5 commits into
base: support/3.2
Choose a base branch
from

Conversation

accognet
Copy link
Contributor

Internal

@accognet accognet added the bug Something isn't working label Mar 22, 2024
@accognet accognet self-assigned this Mar 22, 2024
Copy link
Contributor

@Molkobain Molkobain left a comment

Choose a reason for hiding this comment

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

Review of the current proposition
Mentions are not only for Contact (@ marker by default), it can be for any kind of objects. So your current implementation breaks it for all other classes.

If we are to go further with this ticket, then we must check if the mentioned object matches the marker it begins with.

Use case that led to this PR
When pasting text from an iTop; if the text contains the hyperlink to an object with the same meta data as the mentions, then the mention will be triggered again even if the hyperlink doesn't start with the marker (@ for Contact).

@v-dumas had this behaviour recently and thought it was nice. So there is obviously a discussion to be done, so we all decide what behaviour we want.

@Molkobain
Copy link
Contributor

I'm moving this PR to "Functional review" even though the technical one didn't occur yet, so the important point can be discussed before going any further.

@Molkobain
Copy link
Contributor

Functional review:

  • Expected behavior: Only trigger a mention, if the hyperlink starts with the corresponding marker (e.g. @ for Person)
  • Target version: 3.2.x if code changes are not too risky, 3.3.0 otherwise. Will be determined, once PR is corrected

@jf-cbd jf-cbd added the internal Work made by Combodo label Dec 19, 2024
@rquetiez
Copy link
Contributor

rquetiez commented Jan 28, 2025

Code review : the preceding character must be dehardcoded from '@' to the one given in the configuration, depending on the object class. Also consider a multi-byte safe function.

@accognet accognet force-pushed the feature/7385-on_mention branch from 7334dcc to 43c1633 Compare January 30, 2025 08:19
application/utils.inc.php Outdated Show resolved Hide resolved
application/utils.inc.php Outdated Show resolved Hide resolved
Copy link
Contributor

@rquetiez rquetiez left a comment

Choose a reason for hiding this comment

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

  1. Two little typographic rules to fix
  2. Having utilsTest derived from iTopDataTestCase seems overkill Is there an alternative?
  3. My mistake on my previous review: multi-byte safe function has no sense when it comes to checking the very first character of a byte sequence. Moreover, a test has been added with an emoji as the "marker".

continue;
}
//tests if the name starts with $sMentionPrefix (e.g. '@' for 'Contact' class)
if (str_starts_with($sMatchedName,$sMentionPrefix) === false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

typographic rules: a space is expected after a coma

{
const USE_TRANSACTION = false;
Copy link
Contributor

@rquetiez rquetiez Feb 3, 2025

Choose a reason for hiding this comment

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

This statement is a trap in the future: adding a test altering the data will leave the DB changed.

Disabling transaction is required here because there is a "data provider" that invokes setUp(), causing a false negative error "two many transactions left open". This issue was revealed when the class inheritance was changed from ItopTestCase to ItopDataTestCase.

Solution:

  • Rework the current proposal to move the new tests into a dedicated test class derived from ItopDataTestCase, and leave the existing test class unchanged (derived from ItopTestCase)
  • Fix the existing test class will be done in a separate flow

@@ -653,6 +658,7 @@ public function ToAcronymProvider()
*/
public function testGetMentionedObjectsFromText($sInput, $aExceptedMentionedObjects)
{
MetaModel::GetConfig()->Set('mentions.allowed_classes', ['@' => 'Person','😊#' => 'Team']);
Copy link
Contributor

Choose a reason for hiding this comment

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

typographic rules: a space is expected after a coma

Copy link
Contributor

@rquetiez rquetiez left a comment

Choose a reason for hiding this comment

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

Ok for merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working internal Work made by Combodo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants