class PresenceStatusMessage
A data class representing a presence status message for a user in Microsoft Teams, including message content, expiration time, and publication time.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/communications/presences/status_message.py
6 - 23
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
office365datetime
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
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class Presence 60.5% similar
-
class TranslationStatus 60.1% similar
-
class InvitedUserMessageInfo 57.5% similar
-
class MessageEntry 57.5% similar
-
class RecentAndJoinedTeamsResponse 56.6% similar