diff --git a/apps/ops/src/components/customer/TicketCard.vue b/apps/ops/src/components/customer/TicketCard.vue
index 8fd7a28..90e34ee 100644
--- a/apps/ops/src/components/customer/TicketCard.vue
+++ b/apps/ops/src/components/customer/TicketCard.vue
@@ -23,6 +23,8 @@
+ {{ ticket.issue_type }}
+ {{ ticket.assigned_staff }}
#{{ ticket.legacy_ticket_id || ticket.name }}
{{ ticket.opening_date }}
@@ -64,6 +66,8 @@ defineEmits(['open'])
.tk-badge { font-size: 10px; padding: 1px 8px; }
.tk-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; padding-left: 0; }
.tk-id { font-size: 11px; color: #94a3b8; font-variant-numeric: tabular-nums; }
+.tk-dept { background: #eef2ff; color: #4338ca; font-size: 10px; padding: 1px 8px; display: inline-flex; align-items: center; }
+.tk-assignee { font-size: 11px; color: #64748b; display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.tk-date { font-size: 11px; color: #94a3b8; white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.avatar-stack { display: flex; align-items: center; }
.avatar-stack .avatar-chip { color: #fff; font-size: 9px; font-weight: 600; border: 1.5px solid #fff; margin-left: -8px; }
diff --git a/scripts/migration/migrate_tickets.py b/scripts/migration/migrate_tickets.py
index d09fadb..b5464b1 100644
--- a/scripts/migration/migrate_tickets.py
+++ b/scripts/migration/migrate_tickets.py
@@ -115,10 +115,14 @@ def main():
user_by_email = {r[1]: r[0] for r in pgc.fetchall() if r[1]}
staff_to_user = {}
+ staff_name_by_id = {} # ticket.assign_to → « Prénom Nom » (custom field assigned_staff, cf update_assigned_staff.py)
for s in staff_list:
email = s.get("email", "")
if email and email in user_by_email:
staff_to_user[s["id"]] = user_by_email[email]
+ nm = ((s.get("first_name") or "") + " " + (s.get("last_name") or "")).strip() or (s.get("username") or "")
+ if nm:
+ staff_name_by_id[s["id"]] = nm
# Existing Issue Types
pgc.execute('SELECT name FROM "tabIssue Type"')
@@ -208,6 +212,7 @@ def main():
dept_name = dept_map.get(t.get("dept_id"), None)
cust_name = cust_map.get(t.get("account_id"))
is_important = 1 if t.get("important") else 0
+ assigned_staff = staff_name_by_id.get(t.get("assign_to")) if t.get("assign_to") else None
opening_date = ts_to_dateonly(t.get("date_create"))
opening_time = None
@@ -233,17 +238,17 @@ def main():
naming_series, subject, status, priority, issue_type,
customer, company, opening_date, opening_time,
legacy_ticket_id, is_incident, is_important,
- parent_incident, service_location
+ parent_incident, service_location, assigned_staff
) VALUES (
%s, %s, %s, %s, %s, 0, 0,
'ISS-.YYYY.-', %s, %s, %s, %s,
%s, %s, %s, %s,
- %s, %s, %s, %s, %s
+ %s, %s, %s, %s, %s, %s
)
""", (issue_name, ts, ts, ADMIN, ADMIN,
subject[:255], status, priority, dept_name,
cust_name, COMPANY, opening_date, opening_time,
- tid, 0, is_important, None, None))
+ tid, 0, is_important, None, None, assigned_staff))
ticket_to_issue[tid] = issue_name
i_ok += 1
diff --git a/services/targo-hub/lib/conversation.js b/services/targo-hub/lib/conversation.js
index 679b0bc..2022b9e 100644
--- a/services/targo-hub/lib/conversation.js
+++ b/services/targo-hub/lib/conversation.js
@@ -765,7 +765,11 @@ async function logToLinkedTicket (conv, msg, subject) {
if (!conv || !conv.linkedTickets || !conv.linkedTickets.length) return
const issue = conv.linkedTickets[conv.linkedTickets.length - 1] // le plus récent
if (!issue || !issue.name) return
- const sent = msg.from === 'agent'
+ // Sortant seulement si NOUS écrivons (from=agent) ET pas depuis l'adresse destinataire du ticket
+ // (sinon une réponse depuis un domaine interne @targo — ex. test/employé destinataire — serait mal classée « Sent »).
+ const custEmail = String(conv.email || '').toLowerCase()
+ const fromEmail = String(msg.fromEmail || '').toLowerCase()
+ const sent = msg.from === 'agent' && (!custEmail || fromEmail !== custEmail)
try {
await createCommunication({
communication_type: 'Communication', communication_medium: 'Email',