🔍 Code Extractor

class SocialPost

Maturity: 47

SocialPost is a data class that represents a social media post retrieved from a SharePoint server, encapsulating post content, attachments, overlays, source information, and user engagement data.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/posts/post.py
Lines:
9 - 32
Complexity:
simple

Purpose

This class serves as a data transfer object (DTO) for SharePoint social posts. It structures and holds information about a social post including its attachment (image, document, or video preview), overlays (references to users, documents, sites, tags, or links within the post), the source application that created the post, and information about users who liked the post. It inherits from ClientValue, making it compatible with the Office365 REST API client framework for serialization and deserialization of server responses.

Source Code

class SocialPost(ClientValue):
    """The SocialPost specifies a post read from the server."""

    def __init__(
        self,
        attachment=SocialAttachment(),
        overlays=None,
        source=SocialLink(),
        liker_info=SocialPostActorInfo(),
    ):
        """
        :param SocialAttachment attachment: The Attachment property specifies an image, document preview,
            or video preview attachment.
        :param list[SocialDataOverlay] overlays: The Overlays property is an array of objects in a post, where each
            object represents a user, document, site, tag, or link.
        :param SocialLink source: The Source property specifies the link to a web site (1) associated with the
            application that created the post.
        :param SocialPostActorInfo liker_info: The LikerInfo property specifies information about users who like the
            post.
        """
        self.Attachment = attachment
        self.Overlays = ClientValueCollection(SocialDataOverlay, overlays)
        self.Source = source
        self.LikerInfo = liker_info

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

attachment: A SocialAttachment object specifying an image, document preview, or video preview attached to the post. Defaults to an empty SocialAttachment() instance if not provided. This represents the primary media content of the post.

overlays: An optional list of SocialDataOverlay objects representing entities mentioned or referenced in the post, such as users (@mentions), documents, sites, tags (#hashtags), or links. Can be None or an empty list. These overlays provide rich metadata about the post's content and connections.

source: A SocialLink object that specifies the link to the web application or site that created the post. Defaults to an empty SocialLink() instance. This helps track the origin of the post within the SharePoint ecosystem.

liker_info: A SocialPostActorInfo object containing information about users who have liked the post, including their profiles and engagement metadata. Defaults to an empty SocialPostActorInfo() instance. This tracks social engagement with the post.

Return Value

Instantiation returns a SocialPost object with four main attributes: Attachment (SocialAttachment), Overlays (ClientValueCollection of SocialDataOverlay objects), Source (SocialLink), and LikerInfo (SocialPostActorInfo). The object represents a complete social post structure ready for use with SharePoint social APIs.

Class Interface

Methods

__init__(self, attachment=SocialAttachment(), overlays=None, source=SocialLink(), liker_info=SocialPostActorInfo())

Purpose: Initializes a new SocialPost instance with attachment, overlays, source, and liker information

Parameters:

  • attachment: SocialAttachment object for the post's media content (image, document, or video preview)
  • overlays: Optional list of SocialDataOverlay objects representing entities referenced in the post
  • source: SocialLink object indicating the application or site that created the post
  • liker_info: SocialPostActorInfo object containing information about users who liked the post

Returns: None (constructor)

Attributes

Name Type Description Scope
Attachment SocialAttachment Stores the attachment (image, document preview, or video preview) associated with the post instance
Overlays ClientValueCollection[SocialDataOverlay] A collection of overlay objects representing users, documents, sites, tags, or links mentioned in the post instance
Source SocialLink The link to the web application or site that created the post instance
LikerInfo SocialPostActorInfo Information about users who have liked the post, including their profiles and engagement data instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue
from office365.runtime.client_value_collection import ClientValueCollection
from office365.sharepoint.social.attachment import SocialAttachment
from office365.sharepoint.social.data_overlay import SocialDataOverlay
from office365.sharepoint.social.link import SocialLink
from office365.sharepoint.social.posts.actor_info import SocialPostActorInfo

Usage Example

from office365.sharepoint.social.posts.post import SocialPost
from office365.sharepoint.social.attachment import SocialAttachment
from office365.sharepoint.social.data_overlay import SocialDataOverlay
from office365.sharepoint.social.link import SocialLink
from office365.sharepoint.social.posts.actor_info import SocialPostActorInfo

# Create a basic social post with default values
post = SocialPost()

# Create a social post with specific attachment and source
attachment = SocialAttachment()
source = SocialLink()
liker_info = SocialPostActorInfo()
post = SocialPost(
    attachment=attachment,
    overlays=None,
    source=source,
    liker_info=liker_info
)

# Access post attributes
post_attachment = post.Attachment
post_overlays = post.Overlays
post_source = post.Source
post_likers = post.LikerInfo

# Typically used when deserializing from SharePoint API response
# The Office365 client will automatically populate this object from server data

Best Practices

  • This class is primarily used as a data container and is typically instantiated automatically by the Office365 REST API client when deserializing server responses
  • When creating instances manually, ensure that all parameters are of the correct type (SocialAttachment, list of SocialDataOverlay, SocialLink, SocialPostActorInfo)
  • The Overlays parameter is automatically wrapped in a ClientValueCollection, so you can pass a plain list or None
  • This class inherits from ClientValue, which provides serialization/deserialization capabilities for the Office365 API framework
  • Do not modify the class attributes directly after instantiation unless you understand the implications for the parent ClientValue serialization
  • This is an immutable-style data class; create new instances rather than modifying existing ones for different posts
  • The class does not perform validation on input parameters, so ensure data integrity at the caller level

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SocialPostDefinitionData 81.8% similar

    A data class representing additional information about server-generated social media posts in SharePoint/Office 365, specifically designed for server-to-server communication.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/posts/definition_data.py
  • class SocialAttachment 78.1% similar

    SocialAttachment is a class representing an image, document preview, or video preview attachment in SharePoint Social features.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/attachment.py
  • class SocialPostCreationData 76.9% similar

    A data class representing the content structure for creating social media posts in SharePoint's SocialFeedManager, supporting text with substitution references for mentions, tags, and links.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/posts/creation_data.py
  • class SocialPostDefinitionDataItem 75.3% similar

    A data class representing an item to be inserted in a social media post by replacing a token in the post definition, used exclusively in server-to-server calls within the Office 365 API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/posts/definition_data_item.py
  • class SocialPostReference 75.3% similar

    A class representing a reference to a post in another social thread, used for posts with tags, likes, mentions, or replies in SharePoint social features.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/posts/reference.py
← Back to Browse