feat(psa): attribute posted notes to mapped CW member
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -987,6 +987,21 @@ async def psa_post_to_ticket(
|
|||||||
)
|
)
|
||||||
psa_connection = conn_result.scalar_one_or_none()
|
psa_connection = conn_result.scalar_one_or_none()
|
||||||
|
|
||||||
|
# Look up member mapping for attribution
|
||||||
|
from app.models.psa_member_mapping import PsaMemberMapping
|
||||||
|
|
||||||
|
member_id = None
|
||||||
|
if psa_connection:
|
||||||
|
mapping_result = await db.execute(
|
||||||
|
select(PsaMemberMapping).where(
|
||||||
|
PsaMemberMapping.psa_connection_id == psa_connection.id,
|
||||||
|
PsaMemberMapping.user_id == current_user.id,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
mapping = mapping_result.scalar_one_or_none()
|
||||||
|
if mapping:
|
||||||
|
member_id = mapping.external_member_id
|
||||||
|
|
||||||
# Post note
|
# Post note
|
||||||
try:
|
try:
|
||||||
provider = await get_provider_for_account(current_user.account_id, db)
|
provider = await get_provider_for_account(current_user.account_id, db)
|
||||||
@@ -994,6 +1009,7 @@ async def psa_post_to_ticket(
|
|||||||
ticket_id=session.psa_ticket_id,
|
ticket_id=session.psa_ticket_id,
|
||||||
text=data.content,
|
text=data.content,
|
||||||
note_type=data.note_type,
|
note_type=data.note_type,
|
||||||
|
member_id=member_id,
|
||||||
)
|
)
|
||||||
note_status = "success"
|
note_status = "success"
|
||||||
external_note_id = note_result.id
|
external_note_id = note_result.id
|
||||||
|
|||||||
Reference in New Issue
Block a user