class SocialThread
SocialThread represents a social media thread object containing a root post, replies, actors, and metadata for SharePoint social features.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/thread.py
8 - 38
moderate
Purpose
This class models a social thread in SharePoint's social networking features. It encapsulates all components of a discussion thread including the original post (root post), all replies, participating actors (users, documents, sites, tags), and thread identification. It inherits from ClientValue, making it suitable for serialization and transmission in SharePoint API calls. The class is primarily used for retrieving and representing social feed threads from SharePoint social services.
Source Code
class SocialThread(ClientValue):
"""The SocialThread property provides the object that contains the thread.
For details on the SocialThread type, see section 3.1.5.42."""
def __init__(
self,
thread_id=None,
actors=None,
replies=None,
root_post=SocialPost(),
post_reference=SocialPostReference(),
):
"""
:param str thread_id: The Id property specifies the unique identification of the thread.
:param list[SocialActor] actors: The Actors property is an array that specifies the users who have created
a post in the returned thread and also contains any users, documents, sites, and tags that are referenced
in any of the posts in the returned thread.
:param list[SocialPost] replies: The Replies property returns an array of zero or more reply posts.
The server can return a subset of the reply posts that are stored on the server.
:param SocialPost root_post: The RootPost property returns the root post.
:param SocialPostReference post_reference:
"""
self.Id = thread_id
self.Actors = ClientValueCollection(SocialActor, actors)
self.RootPost = root_post
self.Replies = ClientValueCollection(SocialPost, replies)
self.PostReference = post_reference
@property
def entity_type_name(self):
return "SP.Social.SocialThread"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
thread_id: A string that uniquely identifies the thread. This is the primary identifier used to reference and retrieve the thread from SharePoint. Can be None if not yet assigned.
actors: A list of SocialActor objects representing all users who have created posts in the thread, plus any users, documents, sites, and tags referenced in the thread's posts. Can be None or an empty list if no actors are present.
replies: A list of SocialPost objects representing reply posts to the root post. The server may return a subset of all replies. Can be None or an empty list if there are no replies.
root_post: A SocialPost object representing the original post that started the thread. Defaults to an empty SocialPost() instance if not provided.
post_reference: A SocialPostReference object that provides reference information for the post. Defaults to an empty SocialPostReference() instance if not provided.
Return Value
Instantiation returns a SocialThread object with all properties initialized. The object contains Id (string), Actors (ClientValueCollection of SocialActor), RootPost (SocialPost), Replies (ClientValueCollection of SocialPost), and PostReference (SocialPostReference). The entity_type_name property returns the string 'SP.Social.SocialThread' for SharePoint type identification.
Class Interface
Methods
__init__(self, thread_id=None, actors=None, replies=None, root_post=SocialPost(), post_reference=SocialPostReference())
Purpose: Initializes a new SocialThread instance with thread metadata, posts, and actors
Parameters:
thread_id: Unique string identifier for the thread, can be Noneactors: List of SocialActor objects representing participants and referenced entities, can be Nonereplies: List of SocialPost objects representing reply posts, can be Noneroot_post: SocialPost object for the original post, defaults to empty SocialPost()post_reference: SocialPostReference object for post reference data, defaults to empty SocialPostReference()
Returns: None (constructor)
@property entity_type_name(self) -> str
property
Purpose: Returns the SharePoint entity type name for this class, used for API serialization and type identification
Returns: String 'SP.Social.SocialThread' representing the SharePoint entity type
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Id |
str | Unique identifier for the thread, set from thread_id parameter | instance |
Actors |
ClientValueCollection[SocialActor] | Collection of actors (users, documents, sites, tags) involved in or referenced by the thread | instance |
RootPost |
SocialPost | The original post that started the thread | instance |
Replies |
ClientValueCollection[SocialPost] | Collection of reply posts to the root post, may be a subset of all replies | instance |
PostReference |
SocialPostReference | Reference information for the post | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
from office365.runtime.client_value_collection import ClientValueCollection
from office365.sharepoint.social.actor import SocialActor
from office365.sharepoint.social.posts.post import SocialPost
from office365.sharepoint.social.posts.reference import SocialPostReference
Usage Example
from office365.sharepoint.social.thread import SocialThread
from office365.sharepoint.social.posts.post import SocialPost
from office365.sharepoint.social.actor import SocialActor
from office365.sharepoint.social.posts.reference import SocialPostReference
# Create a new thread with minimal data
thread = SocialThread(thread_id='thread-123')
# Create a thread with full data
root_post = SocialPost()
actor1 = SocialActor()
reply1 = SocialPost()
post_ref = SocialPostReference()
thread = SocialThread(
thread_id='thread-456',
actors=[actor1],
replies=[reply1],
root_post=root_post,
post_reference=post_ref
)
# Access thread properties
thread_id = thread.Id
all_actors = thread.Actors
root = thread.RootPost
all_replies = thread.Replies
reference = thread.PostReference
# Get entity type name for SharePoint API
type_name = thread.entity_type_name # Returns 'SP.Social.SocialThread'
Best Practices
- Always provide a thread_id when creating a thread object that represents an existing SharePoint thread
- Use ClientValueCollection for actors and replies to ensure proper serialization for SharePoint API calls
- The class is immutable after instantiation - properties are set in __init__ and not modified afterward
- This class is typically instantiated by SharePoint API responses rather than manually created
- When manually creating instances, ensure SocialPost and SocialActor objects are properly initialized
- The entity_type_name property is used internally by the Office365 library for type identification in API calls
- Replies may be a subset of all replies - check server documentation for pagination details
- Actors include not just users but also documents, sites, and tags referenced in the thread
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class SocialRestThread 81.7% similar
-
class SocialFeed 79.3% similar
-
class SocialPostReference 77.4% similar
-
class SocialPost 71.7% similar
-
class SocialRestFeed 70.9% similar