class SocialFeed
SocialFeed is a data class representing a social media feed containing threads of posts, with metadata about processed items and unread mentions.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/feed/feed.py
6 - 48
moderate
Purpose
The SocialFeed class represents a social feed structure in SharePoint's social features. It encapsulates an array of SocialThread objects (each containing a root post and response posts), along with metadata such as timestamps of newest/oldest processed posts, feed attributes, and unread mention counts. This class is used to retrieve and manage social content feeds from SharePoint, typically returned by methods like GetFeed or GetMentions in SharePoint's social API.
Source Code
class SocialFeed(ClientValue):
"""
The SocialFeed class specifies a feed, which contains an array of SocialThread (section 3.1.5.42), each of which
specifies a root SocialPost object (section 3.1.5.26) and an array of response SocialPost objects.
"""
def __init__(
self,
attributes=None,
newest_processed=None,
oldest_processed=None,
threads=None,
unread_mention_count=None,
):
"""
:param in attributes: The Attributes property specifies attributes of the returned feed.
The attributes specify if the requested feed has additional threads that were not included in the returned
thread. See section 3.1.5.18 for details on the SocialFeedAttributes type.
:param str newest_processed: The NewestProcessed property returns the date-time of the most recent post that
was requested. If the current user does not have access to the post, the most recent post that was
requested can be removed from the feed, and the feed does not contain the post with the date specified
in this property.
:param str oldest_processed: The OldestProcessed property returns the date-time of the oldest post that was
requested. If the current user does not have access to the post, the oldest post that was requested can
be removed from the feed and the feed does not contain the post with the date specified in this property.
:param list[SocialThread] threads:
:param int unread_mention_count: he UnreadMentionCount property returns the number of mentions of the current
user that have been added to the feed on the server since the time that the unread mention count
was cleared for the current user.
The GetMentions method (see section 3.1.5.19.2.1.7) optionally clears the unread mention count for
the current user.
The UnreadMentionCount property is available only for social feeds returned by the GetFeed method
(see section 3.1.5.19.2.1.4).
"""
self.Attributes = attributes
self.NewestProcessed = newest_processed
self.OldestProcessed = oldest_processed
self.Threads = ClientValueCollection(SocialThread, threads)
self.UnreadMentionCount = unread_mention_count
@property
def entity_type_name(self):
return "SP.Social.SocialFeed"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
attributes: A SocialFeedAttributes object (section 3.1.5.18) that specifies attributes of the returned feed, including whether the feed has additional threads not included in the current response. Can be None if no attributes are specified.
newest_processed: A string representing the date-time (ISO format) of the most recent post that was requested. If the current user lacks access to this post, it may be removed from the feed. Can be None if not applicable.
oldest_processed: A string representing the date-time (ISO format) of the oldest post that was requested. Similar to newest_processed, this post may be removed if the user lacks access. Can be None if not applicable.
threads: A list of SocialThread objects, where each thread contains a root SocialPost and an array of response SocialPost objects. Can be None or an empty list if no threads are present.
unread_mention_count: An integer representing the number of mentions of the current user added to the feed since the unread mention count was last cleared. Only available for feeds returned by the GetFeed method. Can be None if not applicable.
Return Value
Instantiation returns a SocialFeed object with all specified properties initialized. The object contains Attributes (feed attributes), NewestProcessed (datetime string), OldestProcessed (datetime string), Threads (ClientValueCollection of SocialThread objects), and UnreadMentionCount (integer). The entity_type_name property returns the string 'SP.Social.SocialFeed' for SharePoint API serialization.
Class Interface
Methods
__init__(self, attributes=None, newest_processed=None, oldest_processed=None, threads=None, unread_mention_count=None)
Purpose: Initializes a new SocialFeed instance with feed metadata and thread collection
Parameters:
attributes: SocialFeedAttributes object specifying feed attributesnewest_processed: String datetime of most recent processed postoldest_processed: String datetime of oldest processed postthreads: List of SocialThread objects to populate the feedunread_mention_count: Integer count of unread mentions for current user
Returns: None (constructor)
@property entity_type_name(self) -> str
property
Purpose: Returns the SharePoint entity type name for this class used in API serialization
Returns: String 'SP.Social.SocialFeed' representing the SharePoint entity type
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Attributes |
SocialFeedAttributes or None | Stores attributes of the feed indicating if additional threads exist that weren't included in the response | instance |
NewestProcessed |
str or None | Stores the ISO 8601 datetime string of the most recent post that was requested | instance |
OldestProcessed |
str or None | Stores the ISO 8601 datetime string of the oldest post that was requested | instance |
Threads |
ClientValueCollection[SocialThread] | Collection of SocialThread objects, each containing a root post and response posts | instance |
UnreadMentionCount |
int or None | Stores the count of unread mentions for the current user since the count was last cleared | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
from office365.runtime.client_value_collection import ClientValueCollection
from office365.sharepoint.social.thread import SocialThread
Usage Example
from office365.sharepoint.social.feed import SocialFeed
from office365.sharepoint.social.thread import SocialThread
from datetime import datetime
# Create a social feed with threads
threads = []
feed = SocialFeed(
attributes=None,
newest_processed='2024-01-15T10:30:00Z',
oldest_processed='2024-01-01T08:00:00Z',
threads=threads,
unread_mention_count=5
)
# Access feed properties
print(f'Entity type: {feed.entity_type_name}')
print(f'Unread mentions: {feed.UnreadMentionCount}')
print(f'Number of threads: {len(feed.Threads)}')
print(f'Newest processed: {feed.NewestProcessed}')
# Typically used when receiving data from SharePoint API
# context = ClientContext(site_url).with_credentials(credentials)
# social_feed_manager = context.web.social_feed_manager
# feed = social_feed_manager.get_feed().execute_query()
# for thread in feed.Threads:
# print(thread.RootPost.Text)
Best Practices
- This class is typically instantiated by SharePoint API responses rather than manually created by developers
- The Threads property is a ClientValueCollection, which provides collection-like behavior for SocialThread objects
- Always check if optional properties (attributes, newest_processed, oldest_processed, unread_mention_count) are None before using them
- The entity_type_name property is used internally for SharePoint API serialization and should not be modified
- UnreadMentionCount is only meaningful for feeds returned by GetFeed method, not other feed retrieval methods
- Date-time strings in NewestProcessed and OldestProcessed should be in ISO 8601 format
- This class inherits from ClientValue, making it suitable for SharePoint client-side object model operations
- The feed may not contain posts referenced by NewestProcessed or OldestProcessed if the user lacks access permissions
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class SocialRestFeed 85.2% similar
-
class SocialThread 79.3% similar
-
class SocialRestFeedManager 76.0% similar
-
class SocialPost 73.4% similar
-
class MicrofeedData 72.4% similar