🔍 Code Extractor

class PresenceStatusMessage

Maturity: 47

A data class representing a presence status message for a user in Microsoft Teams, including message content, expiration time, and publication time.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/communications/presences/status_message.py
Lines:
6 - 23
Complexity:
simple

Purpose

This class encapsulates the data structure for Microsoft Teams presence status messages. It inherits from ClientValue and is used to represent temporary status messages that users can set in Teams, such as 'In a meeting' or 'Out of office'. The class manages three key pieces of information: when the message expires, the message content itself, and when it was published. It's typically used in conjunction with Microsoft Graph API operations related to user presence.

Source Code

class PresenceStatusMessage(ClientValue):
    """Represents a presence status message related to the presence of a user in Microsoft Teams."""

    def __init__(
        self,
        expiry_datetime=DateTimeTimeZone(),
        message=ItemBody(),
        published_datetime=None,
    ):
        """
        :param DateTimeTimeZone expiry_datetime: Time in which the status message expires. If not provided, the status
            message does not expire.
        :param ItemBody message: Status message item.
        :param datetime.datetime published_datetime: Time in which the status message was published.
        """
        self.expiryDateTime = expiry_datetime
        self.message = message
        self.publishedDateTime = published_datetime

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

expiry_datetime: A DateTimeTimeZone object specifying when the status message should expire. If not provided or set to default, the status message does not expire. This allows for temporary status messages that automatically clear after a certain time.

message: An ItemBody object containing the actual status message text and format. This represents the content that will be displayed as the user's presence status in Microsoft Teams.

published_datetime: A datetime.datetime object indicating when the status message was originally published. Can be None if not yet published or if the publication time is unknown. This is typically set by the server when the status is created.

Return Value

Instantiation returns a PresenceStatusMessage object with three attributes: expiryDateTime (DateTimeTimeZone), message (ItemBody), and publishedDateTime (datetime.datetime or None). This object can be serialized and sent to Microsoft Graph API or used to represent presence data retrieved from the API.

Class Interface

Methods

__init__(self, expiry_datetime=DateTimeTimeZone(), message=ItemBody(), published_datetime=None)

Purpose: Initializes a new PresenceStatusMessage instance with expiration time, message content, and publication time

Parameters:

  • expiry_datetime: DateTimeTimeZone object for when the status expires (default: empty DateTimeTimeZone)
  • message: ItemBody object containing the status message content (default: empty ItemBody)
  • published_datetime: datetime.datetime object for when the status was published (default: None)

Returns: None (constructor)

Attributes

Name Type Description Scope
expiryDateTime DateTimeTimeZone Stores the date and time when the status message expires. If not set or default, the message doesn't expire. instance
message ItemBody Stores the actual status message content and format (text or HTML) that will be displayed in Microsoft Teams. instance
publishedDateTime datetime.datetime or None Stores the timestamp when the status message was published. Typically set by the server, can be None for unpublished messages. instance

Dependencies

  • office365
  • datetime

Required Imports

from office365.outlook.calendar.dateTimeTimeZone import DateTimeTimeZone
from office365.outlook.mail.item_body import ItemBody
from office365.runtime.client_value import ClientValue

Usage Example

from office365.outlook.calendar.dateTimeTimeZone import DateTimeTimeZone
from office365.outlook.mail.item_body import ItemBody
from office365.entity_collection import PresenceStatusMessage
from datetime import datetime, timedelta

# Create a status message that expires in 2 hours
expiry = DateTimeTimeZone()
expiry.dateTime = (datetime.now() + timedelta(hours=2)).isoformat()
expiry.timeZone = 'UTC'

# Create the message body
message_body = ItemBody()
message_body.content = 'In a meeting'
message_body.contentType = 'text'

# Create the presence status message
status_msg = PresenceStatusMessage(
    expiry_datetime=expiry,
    message=message_body,
    published_datetime=datetime.now()
)

# Access attributes
print(status_msg.expiryDateTime)
print(status_msg.message.content)
print(status_msg.publishedDateTime)

Best Practices

  • Always provide a valid DateTimeTimeZone object for expiry_datetime if you want the status to expire automatically
  • Use ItemBody with appropriate contentType ('text' or 'html') when setting the message
  • The publishedDateTime is typically set by the server, so it's usually None when creating a new status message
  • This class inherits from ClientValue, which means it's designed to be serialized/deserialized for API communication
  • Don't modify attributes directly after creation if the object is being used in an API context; create a new instance instead
  • Ensure timezone information is properly set in DateTimeTimeZone objects to avoid confusion across different time zones
  • This is a data transfer object (DTO) - it doesn't have business logic methods, only data storage

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class Presence 60.5% similar

    Contains information about a user's presence, including their availability and user activity.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/communications/presences/presence.py
  • class TranslationStatus 60.1% similar

    TranslationStatus is a simple data class that inherits from ClientValue, representing the status of a translation operation in the Office365 API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/translation/status.py
  • class InvitedUserMessageInfo 57.5% similar

    A data class that configures invitation messages for invited users, including CC recipients, custom message body, and language preferences.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/invitations/message_info.py
  • class MessageEntry 57.5% similar

    A data class representing a message entry in Microsoft SharePoint, inheriting from ClientValue to provide serialization capabilities for SharePoint API interactions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/gtp/message_entry.py
  • class RecentAndJoinedTeamsResponse 56.6% similar

    A data transfer object representing a response containing information about recent and joined Microsoft Teams in SharePoint Portal.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/teams/recent_and_joined_response.py
← Back to Browse