Skip to content

Commit

Permalink
Made change so that sendUri works properly with Facebook profile pages
Browse files Browse the repository at this point in the history
Facebook profiles pages are treated differently from other urls
  • Loading branch information
gitCommitWiL committed Apr 7, 2020
1 parent c6a3f21 commit 27028f5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions fbchat/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,18 +1089,25 @@ def sendUri(self, uri, message=None, thread_id=None, thread_type=ThreadType.USER
if message is not None:
data.update(message._to_send_data())
data["action_type"] = "ma-type:user-generated-message"
data["has_attachment"] = True
data["shareable_attachment[share_type]"] = urlData["share_type"]
for key in urlData["share_params"]:
if isinstance(urlData["share_params"][key], dict):
for key2 in urlData["share_params"][key]:
data[
"shareable_attachment[share_params][{}][{}]".format(key, key2)
] = urlData["share_params"][key][key2]
else:
data["shareable_attachment[share_params][{}]".format(key)] = urlData[
"share_params"
][key]
# most uri params will come back as dict
if isinstance(urlData['share_params'], dict):
data["has_attachment"] = True
for key in urlData["share_params"]:
if isinstance(urlData["share_params"][key], dict):
for key2 in urlData["share_params"][key]:
data[
"shareable_attachment[share_params][{}][{}]".format(key, key2)
] = urlData["share_params"][key][key2]
else:
data["shareable_attachment[share_params][{}]".format(key)] = urlData[
"share_params"
][key]
# some (such as facebook profile pages) will just be a list
else:
data["has_attachment"] = False
for index, val in enumerate(urlData['share_params']):
data['shareable_attachment[share_params][{}]'.format(index)] = val
return self._doSendRequest(data)

def sendEmoji(
Expand Down

0 comments on commit 27028f5

Please sign in to comment.