Skip to content

Commit

Permalink
Fix #1240 Update chat_unfurl to support source/unfurl_id parameters (#…
Browse files Browse the repository at this point in the history
…1241)

* Fix #1240 Update chat_unfurl to support source/unfurl_id parameters

* Fix a bug
  • Loading branch information
seratch authored Jul 19, 2022
1 parent e4ccb13 commit 5ae7089
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
8 changes: 6 additions & 2 deletions slack_sdk/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2121,8 +2121,10 @@ async def chat_scheduleMessage(
async def chat_unfurl(
self,
*,
channel: str,
ts: str,
channel: Optional[str] = None,
ts: Optional[str] = None,
source: Optional[str] = None,
unfurl_id: Optional[str] = None,
unfurls: Dict[str, Dict],
user_auth_blocks: Optional[Sequence[Union[Dict, Block]]] = None,
user_auth_message: Optional[str] = None,
Expand All @@ -2137,6 +2139,8 @@ async def chat_unfurl(
{
"channel": channel,
"ts": ts,
"source": source,
"unfurl_id": unfurl_id,
"unfurls": unfurls,
"user_auth_blocks": user_auth_blocks,
"user_auth_message": user_auth_message,
Expand Down
8 changes: 6 additions & 2 deletions slack_sdk/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2112,8 +2112,10 @@ def chat_scheduleMessage(
def chat_unfurl(
self,
*,
channel: str,
ts: str,
channel: Optional[str] = None,
ts: Optional[str] = None,
source: Optional[str] = None,
unfurl_id: Optional[str] = None,
unfurls: Dict[str, Dict],
user_auth_blocks: Optional[Sequence[Union[Dict, Block]]] = None,
user_auth_message: Optional[str] = None,
Expand All @@ -2128,6 +2130,8 @@ def chat_unfurl(
{
"channel": channel,
"ts": ts,
"source": source,
"unfurl_id": unfurl_id,
"unfurls": unfurls,
"user_auth_blocks": user_auth_blocks,
"user_auth_message": user_auth_message,
Expand Down
8 changes: 6 additions & 2 deletions slack_sdk/web/legacy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2123,8 +2123,10 @@ def chat_scheduleMessage(
def chat_unfurl(
self,
*,
channel: str,
ts: str,
channel: Optional[str] = None,
ts: Optional[str] = None,
source: Optional[str] = None,
unfurl_id: Optional[str] = None,
unfurls: Dict[str, Dict],
user_auth_blocks: Optional[Sequence[Union[Dict, Block]]] = None,
user_auth_message: Optional[str] = None,
Expand All @@ -2139,6 +2141,8 @@ def chat_unfurl(
{
"channel": channel,
"ts": ts,
"source": source,
"unfurl_id": unfurl_id,
"unfurls": unfurls,
"user_auth_blocks": user_auth_blocks,
"user_auth_message": user_auth_message,
Expand Down
17 changes: 15 additions & 2 deletions tests/slack_sdk_async/web/test_web_client_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@


class TestWebClientCoverage(unittest.TestCase):
# 227 endpoints as of Feb 16, 2022
# 229 endpoints as of July 18, 2022
# Can be fetched by running `var methodNames = [].slice.call(document.getElementsByClassName('apiReferenceFilterableList__listItemLink')).map(e => e.href.replace("https://api.slack.com/methods/", ""));console.log(methodNames.toString());console.log(methodNames.length);` on https://api.slack.com/methods
all_api_methods = "admin.analytics.getFile,admin.apps.approve,admin.apps.clearResolution,admin.apps.restrict,admin.apps.uninstall,admin.apps.approved.list,admin.apps.requests.cancel,admin.apps.requests.list,admin.apps.restricted.list,admin.auth.policy.assignEntities,admin.auth.policy.getEntities,admin.auth.policy.removeEntities,admin.barriers.create,admin.barriers.delete,admin.barriers.list,admin.barriers.update,admin.conversations.archive,admin.conversations.convertToPrivate,admin.conversations.create,admin.conversations.delete,admin.conversations.disconnectShared,admin.conversations.getConversationPrefs,admin.conversations.getCustomRetention,admin.conversations.getTeams,admin.conversations.invite,admin.conversations.removeCustomRetention,admin.conversations.rename,admin.conversations.search,admin.conversations.setConversationPrefs,admin.conversations.setCustomRetention,admin.conversations.setTeams,admin.conversations.unarchive,admin.conversations.ekm.listOriginalConnectedChannelInfo,admin.conversations.restrictAccess.addGroup,admin.conversations.restrictAccess.listGroups,admin.conversations.restrictAccess.removeGroup,admin.emoji.add,admin.emoji.addAlias,admin.emoji.list,admin.emoji.remove,admin.emoji.rename,admin.inviteRequests.approve,admin.inviteRequests.deny,admin.inviteRequests.list,admin.inviteRequests.approved.list,admin.inviteRequests.denied.list,admin.teams.admins.list,admin.teams.create,admin.teams.list,admin.teams.owners.list,admin.teams.settings.info,admin.teams.settings.setDefaultChannels,admin.teams.settings.setDescription,admin.teams.settings.setDiscoverability,admin.teams.settings.setIcon,admin.teams.settings.setName,admin.usergroups.addChannels,admin.usergroups.addTeams,admin.usergroups.listChannels,admin.usergroups.removeChannels,admin.users.assign,admin.users.invite,admin.users.list,admin.users.remove,admin.users.setAdmin,admin.users.setExpiration,admin.users.setOwner,admin.users.setRegular,admin.users.session.clearSettings,admin.users.session.getSettings,admin.users.session.invalidate,admin.users.session.list,admin.users.session.reset,admin.users.session.resetBulk,admin.users.session.setSettings,admin.users.unsupportedVersions.export,api.test,apps.connections.open,apps.event.authorizations.list,apps.manifest.create,apps.manifest.delete,apps.manifest.export,apps.manifest.update,apps.manifest.validate,apps.uninstall,auth.revoke,auth.test,auth.teams.list,bookmarks.add,bookmarks.edit,bookmarks.list,bookmarks.remove,bots.info,calls.add,calls.end,calls.info,calls.update,calls.participants.add,calls.participants.remove,chat.delete,chat.deleteScheduledMessage,chat.getPermalink,chat.meMessage,chat.postEphemeral,chat.postMessage,chat.scheduleMessage,chat.unfurl,chat.update,chat.scheduledMessages.list,conversations.acceptSharedInvite,conversations.approveSharedInvite,conversations.archive,conversations.close,conversations.create,conversations.declineSharedInvite,conversations.history,conversations.info,conversations.invite,conversations.inviteShared,conversations.join,conversations.kick,conversations.leave,conversations.list,conversations.listConnectInvites,conversations.mark,conversations.members,conversations.open,conversations.rename,conversations.replies,conversations.setPurpose,conversations.setTopic,conversations.unarchive,dialog.open,dnd.endDnd,dnd.endSnooze,dnd.info,dnd.setSnooze,dnd.teamInfo,emoji.list,files.comments.delete,files.delete,files.info,files.list,files.revokePublicURL,files.sharedPublicURL,files.upload,files.remote.add,files.remote.info,files.remote.list,files.remote.remove,files.remote.share,files.remote.update,migration.exchange,oauth.access,oauth.v2.access,oauth.v2.exchange,openid.connect.token,openid.connect.userInfo,pins.add,pins.list,pins.remove,reactions.add,reactions.get,reactions.list,reactions.remove,reminders.add,reminders.complete,reminders.delete,reminders.info,reminders.list,rtm.connect,rtm.start,search.all,search.files,search.messages,stars.add,stars.list,stars.remove,team.accessLogs,team.billableInfo,team.info,team.integrationLogs,team.billing.info,team.preferences.list,team.profile.get,tooling.tokens.rotate,usergroups.create,usergroups.disable,usergroups.enable,usergroups.list,usergroups.update,usergroups.users.list,usergroups.users.update,users.conversations,users.deletePhoto,users.getPresence,users.identity,users.info,users.list,users.lookupByEmail,users.setActive,users.setPhoto,users.setPresence,users.profile.get,users.profile.set,views.open,views.publish,views.push,views.update,workflows.stepCompleted,workflows.stepFailed,workflows.updateStep,channels.create,channels.info,channels.invite,channels.mark,groups.create,groups.info,groups.invite,groups.mark,groups.open,im.list,im.mark,im.open,mpim.list,mpim.mark,mpim.open".split(
all_api_methods = "admin.analytics.getFile,admin.apps.approve,admin.apps.clearResolution,admin.apps.restrict,admin.apps.uninstall,admin.apps.approved.list,admin.apps.requests.cancel,admin.apps.requests.list,admin.apps.restricted.list,admin.audit.anomaly.allow.getItem,admin.audit.anomaly.allow.updateItem,admin.auth.policy.assignEntities,admin.auth.policy.getEntities,admin.auth.policy.removeEntities,admin.barriers.create,admin.barriers.delete,admin.barriers.list,admin.barriers.update,admin.conversations.archive,admin.conversations.convertToPrivate,admin.conversations.create,admin.conversations.delete,admin.conversations.disconnectShared,admin.conversations.getConversationPrefs,admin.conversations.getCustomRetention,admin.conversations.getTeams,admin.conversations.invite,admin.conversations.removeCustomRetention,admin.conversations.rename,admin.conversations.search,admin.conversations.setConversationPrefs,admin.conversations.setCustomRetention,admin.conversations.setTeams,admin.conversations.unarchive,admin.conversations.ekm.listOriginalConnectedChannelInfo,admin.conversations.restrictAccess.addGroup,admin.conversations.restrictAccess.listGroups,admin.conversations.restrictAccess.removeGroup,admin.emoji.add,admin.emoji.addAlias,admin.emoji.list,admin.emoji.remove,admin.emoji.rename,admin.inviteRequests.approve,admin.inviteRequests.deny,admin.inviteRequests.list,admin.inviteRequests.approved.list,admin.inviteRequests.denied.list,admin.teams.admins.list,admin.teams.create,admin.teams.list,admin.teams.owners.list,admin.teams.settings.info,admin.teams.settings.setDefaultChannels,admin.teams.settings.setDescription,admin.teams.settings.setDiscoverability,admin.teams.settings.setIcon,admin.teams.settings.setName,admin.usergroups.addChannels,admin.usergroups.addTeams,admin.usergroups.listChannels,admin.usergroups.removeChannels,admin.users.assign,admin.users.invite,admin.users.list,admin.users.remove,admin.users.setAdmin,admin.users.setExpiration,admin.users.setOwner,admin.users.setRegular,admin.users.session.clearSettings,admin.users.session.getSettings,admin.users.session.invalidate,admin.users.session.list,admin.users.session.reset,admin.users.session.resetBulk,admin.users.session.setSettings,admin.users.unsupportedVersions.export,api.test,apps.connections.open,apps.event.authorizations.list,apps.manifest.create,apps.manifest.delete,apps.manifest.export,apps.manifest.update,apps.manifest.validate,apps.uninstall,auth.revoke,auth.test,auth.teams.list,bookmarks.add,bookmarks.edit,bookmarks.list,bookmarks.remove,bots.info,calls.add,calls.end,calls.info,calls.update,calls.participants.add,calls.participants.remove,chat.delete,chat.deleteScheduledMessage,chat.getPermalink,chat.meMessage,chat.postEphemeral,chat.postMessage,chat.scheduleMessage,chat.unfurl,chat.update,chat.scheduledMessages.list,conversations.acceptSharedInvite,conversations.approveSharedInvite,conversations.archive,conversations.close,conversations.create,conversations.declineSharedInvite,conversations.history,conversations.info,conversations.invite,conversations.inviteShared,conversations.join,conversations.kick,conversations.leave,conversations.list,conversations.listConnectInvites,conversations.mark,conversations.members,conversations.open,conversations.rename,conversations.replies,conversations.setPurpose,conversations.setTopic,conversations.unarchive,dialog.open,dnd.endDnd,dnd.endSnooze,dnd.info,dnd.setSnooze,dnd.teamInfo,emoji.list,files.comments.delete,files.delete,files.info,files.list,files.revokePublicURL,files.sharedPublicURL,files.upload,files.remote.add,files.remote.info,files.remote.list,files.remote.remove,files.remote.share,files.remote.update,migration.exchange,oauth.access,oauth.v2.access,oauth.v2.exchange,openid.connect.token,openid.connect.userInfo,pins.add,pins.list,pins.remove,reactions.add,reactions.get,reactions.list,reactions.remove,reminders.add,reminders.complete,reminders.delete,reminders.info,reminders.list,rtm.connect,rtm.start,search.all,search.files,search.messages,stars.add,stars.list,stars.remove,team.accessLogs,team.billableInfo,team.info,team.integrationLogs,team.billing.info,team.preferences.list,team.profile.get,tooling.tokens.rotate,usergroups.create,usergroups.disable,usergroups.enable,usergroups.list,usergroups.update,usergroups.users.list,usergroups.users.update,users.conversations,users.deletePhoto,users.getPresence,users.identity,users.info,users.list,users.lookupByEmail,users.setActive,users.setPhoto,users.setPresence,users.profile.get,users.profile.set,views.open,views.publish,views.push,views.update,workflows.stepCompleted,workflows.stepFailed,workflows.updateStep,channels.create,channels.info,channels.invite,channels.mark,groups.create,groups.info,groups.invite,groups.mark,groups.open,im.list,im.mark,im.open,mpim.list,mpim.mark,mpim.open".split(
","
)

Expand Down Expand Up @@ -48,6 +48,9 @@ def setUp(self):
"apps.manifest.update",
"apps.manifest.validate",
"tooling.tokens.rotate",
# TODO: admin.audit.anomaly.allow.* / The endpoints requires a "session" token
"admin.audit.anomaly.allow.getItem",
"admin.audit.anomaly.allow.updateItem",
]:
continue
self.api_methods_to_call.append(api_method)
Expand Down Expand Up @@ -432,6 +435,16 @@ async def run_method(self, method_name, method, async_method):
ts="123.123",
unfurls={"https://example.com/": {"text": "Every day is the test."}},
)
method(
source="composer",
unfurl_id="Uxxxxxxx-909b5454-75f8-4ac4-b325-1b40e230bbd8",
unfurls={"https://example.com/": {"text": "Every day is the test."}},
)
await async_method(
source="composer",
unfurl_id="Uxxxxxxx-909b5454-75f8-4ac4-b325-1b40e230bbd8",
unfurls={"https://example.com/": {"text": "Every day is the test."}},
)
elif method_name == "chat_update":
self.api_methods_to_call.remove(method(channel="C123", ts="123.123")["method"])
await async_method(channel="C123", ts="123.123")
Expand Down

0 comments on commit 5ae7089

Please sign in to comment.