Body: <p>In CRM_SMS_Provider::processInbound, there are the lines</p>
  
  <pre><code>'source_contact_id' =&gt; $toContactID,
  'target_contact_id' =&gt; $fromContactID,
  </code></pre>
  
  <p>which suggests that the source contact of the activity will be 'us', and the target will be the remote contact, who sent the message.</p>
  
  <p>This is not the same as Inbound Email, which in _civicrm_api3_deprecated_activity_buildmailparams sets the source contact to the sender, and the targets as an array of recipients.</p>
  
  <p>This is not going to be an issue for most users, as neither Clickatell nor Twilio extensions pass the 'To' number through to processInbound, and in this case the target will be set to the same as the source, attaching the activity to only the remote contact. It can arise if one uses a provider extension that does pass the 'To' number to processInbound, or Clickatell or Twilio have been appropriately modified, for example so messages received on multiple inbound lines can be told apart.</p>
  
  <p>Should the source contact be the sender?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-25T11:27:13.590Z
Comments.Text: Previously asked on the forum: https://forum.civicrm.org/index.php?topic=35756.0 I'm trying to clear out old issues on our bug tracker here at FF.
Comments.UserDisplayName: DaveFF
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-25T11:34:17.080Z
Comments.Text: Another custom thing we've done in CRM_SMS_Provider, is checking for duplicate message tracking IDs and bodies on inbound messages- in a couple of cases we had a message hit us more than once from the provider.
Comments.UserDisplayName: DaveFF
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-25T12:03:18.873Z
Comments.Text: I have thought of the exact same thing. It seems weird that source and target contacts are the same, since that does not reflect real life action.
Comments.UserDisplayName: Flying
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-07T20:06:33.867Z
Comments.Text: @DaveFF for an example of "messages received on multiple inbound lines can be told apart" see inbound() in https://github.com/HikerBoricua/org.civicrm.sms.twilio/blob/master/org_civicrm_sms_twilio.php. It lives with the from/to direction as is, would have to change if Core is updated. Our use case is precisely what you said, each Twilio phone number receives inbound texts for a specific staff person.
Comments.UserDisplayName: wil_SRQ
Tags: <sms><civisms>
Title: Are source/target contacts on Inbound SMS the wrong way round?
ThreadText: # Are source/target contacts on Inbound SMS the wrong way round?
  
  (Asked by: username_0 on 2015-11-25)
  
  In CRM_SMS_Provider::processInbound, there are the lines
  'source_contact_id' => $toContactID,
  'target_contact_id' => $fromContactID,
  
  which suggests that the source contact of the activity will be 'us', and the target will be the remote contact, who sent the message.
  This is not the same as Inbound Email, which in _civicrm_api3_deprecated_activity_buildmailparams sets the source contact to the sender, and the targets as an array of recipients.
  This is not going to be an issue for most users, as neither Clickatell nor Twilio extensions pass the 'To' number through to processInbound, and in this case the target will be set to the same as the source, attaching the activity to only the remote contact. It can arise if one uses a provider extension that does pass the 'To' number to processInbound, or Clickatell or Twilio have been appropriately modified, for example so messages received on multiple inbound lines can be told apart.
  Should the source contact be the sender?
  
  **Tags:** sms, civisms
  
  > **Comments:**
  > **username_0**: Previously asked on the forum: https://forum.civicrm.org/index.php?topic=35756.0 I'm trying to clear out old issues on our bug tracker here at FF.  
  > **username_0**: Another custom thing we've done in CRM_SMS_Provider, is checking for duplicate message tracking IDs and bodies on inbound messages- in a couple of cases we had a message hit us more than once from the provider.  
  > **username_1**: I have thought of the exact same thing. It seems weird that source and target contacts are the same, since that does not reflect real life action.  
  > **username_2**: @username_0 for an example of "messages received on multiple inbound lines can be told apart" see inbound() in https://github.com/HikerBoricua/org.civicrm.sms.twilio/blob/master/org_civicrm_sms_twilio.php. It lives with the from/to direction as is, would have to change if Core is updated. Our use case is precisely what you said, each Twilio phone number receives inbound texts for a specific staff person.  
  
  ---
  
  ## 0 answers
  
  