Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS][Chat][Interop] File Sharing GA #33938

Merged
merged 8 commits into from
Mar 28, 2024
Merged

Conversation

jpeng-ms
Copy link
Member

@jpeng-ms jpeng-ms commented Jan 22, 2024

Description

we are releasing file sharing to GA. File sharing has been previously released as public beta for Chat SDK for JS. And now we are introducing this feature to Chat SDK for Python

Swagger: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/f579ddcd291d55b0a2a32ee81995432458db3da9/specification/communication/data-plane/Chat/readme.md

Contoso use case:

    def list_messages(self):
        thread_id = self._thread_id
        chat_client = self._chat_client
        # [START list_messages]
        from datetime import datetime, timedelta

        # set `thread_id` to an existing thread id
        chat_thread_client = chat_client.get_chat_thread_client(thread_id=thread_id)
        print(chat_thread_client)
        start_time = datetime.utcnow() - timedelta(days=1)
        chat_messages = chat_thread_client.list_messages(results_per_page=1, start_time=start_time)

        print("list_messages succeeded with results_per_page is 1, and start time is yesterday UTC")
        for chat_message_page in chat_messages.by_page():
            for chat_message in chat_message_page:
                print("------")
                print("ChatMessage: message=", chat_message.content.message)
                for attachment in chat_message.content.attachments:
                    print("ChatMessage: attachmentId=", attachment.id)
                    print("ChatMessage: attachmentName=", attachment.name)
                    print("ChatMessage: attachmentType=", attachment.attachment_type)
                    print("ChatMessage: attachmentPreviewUrl=", attachment.preview_url)
        # [END list_messages]
        print("list_messages succeeded")

If contoso has an UI application, they can create a button links to preview_url which will navigate them to a sharepoint page where they can download the file:

from tkinter import *
import webbrowser

root = Tk()
root.title("Chat Thread")
root.geometry("700x500")
root.config(bg="#3062C7")

def links_unit1():
    bg_v1 = Canvas(root, bg="#3062C7", width=700, height=500)
    bg_v1.place(x=0, y=0)

    vid_1 = Button(root, text="Open File",
                   command=lambda: webbrowser.open(attachment.preview_url))
    vid_1.place(x=20, y=20)


vid_unit1 = Button(root, text="Chat", command=links_unit1)
vid_unit1.place(x=10, y=10)

root.mainloop()
image

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-communication-chat

@jpeng-ms jpeng-ms marked this pull request as ready for review February 16, 2024 07:18
@jpeng-ms
Copy link
Member Author

/azp run prepare-pipelines

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jpeng-ms
Copy link
Member Author

/azp run python-communication-ci

Copy link

No pipelines are associated with this pull request.

@jpeng-ms
Copy link
Member Author

/azp run python - communication - ci

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jpeng-ms
Copy link
Member Author

/azp run python - communication - ci

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@LuChen-Microsoft LuChen-Microsoft merged commit 04e6769 into main Mar 28, 2024
21 checks passed
@LuChen-Microsoft LuChen-Microsoft deleted the feature/file-sharing-ga branch March 28, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants