Skip to content

N°9527 - Avoid multiple notifications on user mentionned on ticket with children - #991

Open
v-dumas wants to merge 1 commit into
developfrom
feature/9527-Prevent-mention-propagation-on-child-ticket
Open

N°9527 - Avoid multiple notifications on user mentionned on ticket with children#991
v-dumas wants to merge 1 commit into
developfrom
feature/9527-Prevent-mention-propagation-on-child-ticket

Conversation

@v-dumas

@v-dumas v-dumas commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Base information

Question Answer
Related to a Combodo ticket?
Type of change? Enhancement

Symptom (bug) / Objective (enhancement)

When a Person is mentioned on a parent Ticket within a log entry, that log entry is copied on the children tickets as is, which result in multiple notification of the same person for the same topic

Proposed solution (bug and enhancement)

The idea is to clean the copied log entry, removing the part which trigger the TriggerOnMention

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have tested all changes I made on an iTop instance
  • I have added a unit test, otherwise I have explained why I couldn't
  • Is the PR clear and detailed enough so anyone can understand without digging in the code?

Copilot AI balanced review requested due to automatic review settings August 4, 2026 12:15
@CombodoApplicationsAccount CombodoApplicationsAccount added the internal Work made by Combodo label Aug 4, 2026
@v-dumas
v-dumas requested review from steffunky and removed request for Copilot August 4, 2026 12:15
@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR sanitizes copied parent-ticket log entries to prevent mentions from triggering duplicate notifications on child tickets.

  • Removes mention-specific object metadata from copied HTML anchors.
  • Clarifies the UpdateChildTicketLog method documentation.

Confidence Score: 5/5

The PR appears safe to merge because no eligible blocking failure or outstanding prior finding remains.

No blocking failure remains.

Important Files Changed

Filename Overview
datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml Cleans mention metadata from parent log HTML before propagating the entry to child tickets.

Reviews (2): Last reviewed commit: "N°9527 - Multi notifications when user m..." | Re-trigger Greptile

&& MetaModel::IsValidAttCode($sChildClass, $sChildAttCode) && MetaModel::GetAttributeDef($sChildClass, $sChildAttCode) instanceof AttributeCaseLog
&& (!utils::IsNullOrEmptyString($this->Get($sParentAttCode)->GetModifiedEntry('html')))) {
$aChildEntries[$sChildAttCode] = Dict::Format('Class:'.$sParentClass.'/Method:UpdateChildTicketWith:'.$sParentAttCode, $this->GetKey(), $this->Get('ref')).$this->Get($sParentAttCode)->GetModifiedEntry('html');
$sCleanedEntry = preg_replace('/<a\s*([^>]*)data-object-class="([^"]*)"\s.*data-object-key="([^"]*)"\s*([^>]*)>@/Ui','<a\1\4>',$this->Get($sParentAttCode)->GetModifiedEntry('html'));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The @ is hardcoded here. But this value comes from the array configuration parameter mentions.allowed_classes which can hold multiple mention triggering character (@, #, ? etc..) and may be interpreted not as character but as joker or placeholder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Moreover, this is removing the data-object-class and data-object-key metadata which may be used by other features, you should not remove them.

Maybe the real fix (but it has to be discussed) would be that a mention adds a dedicated HTML metadata in addition to data-object-class / data-object-key which should be the one triggering the mention notification. That way you could stip this one without impacting other features.

Copilot AI 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.

Pull request overview

Prevents duplicate mention notifications when parent-ticket log entries propagate to children.

Changes:

  • Removes mention metadata from copied @ links.
  • Updates the method comment wording.
Suppressed comments (2)

datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml:386

  • The .* can backtrack past the current closing > into later anchors. For example, an object link followed on the same line by an @Person mention can be matched as one span, causing this replacement to delete the first link and all intervening visible content. Keep attribute matching inside the current opening tag (or parse the HTML structurally).
			  $sCleanedEntry = preg_replace('/<a\s*([^>]*)data-object-class="([^"]*)"\s.*data-object-key="([^"]*)"\s*([^>]*)>@/Ui','<a\1\4>',$this->Get($sParentAttCode)->GetModifiedEntry('html'));

datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml:386

  • The new sanitization behavior has no regression test, although this method already has dedicated coverage in tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-tickets/UpdateChildTicketLogTest.php. Add a parent entry containing a Person mention and multiple children, then assert copied entries are no longer returned by utils::GetMentionedObjectsFromText; include an ordinary object link before the mention to guard against cross-anchor content loss.
			  $sCleanedEntry = preg_replace('/<a\s*([^>]*)data-object-class="([^"]*)"\s.*data-object-key="([^"]*)"\s*([^>]*)>@/Ui','<a\1\4>',$this->Get($sParentAttCode)->GetModifiedEntry('html'));

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +353 to 354
* Remove the Person associated with the current user from the contacts_list of this Ticket
* No error if there is no associated Person or if the Person is not in the list

@Molkobain Molkobain left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comment in Steffunky thread

@v-dumas

v-dumas commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

There is another PR which aims to replace the regexp with a Xpath, as a result, I will stop this one until we have agreed on a common strategy

@v-dumas v-dumas closed this Aug 12, 2026
@v-dumas v-dumas reopened this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants