コード例 #1
0
        private Task AddContextToMastodonPost(MastodonPost post, MastodonPostContextOptions mastodonPostContextOptions)
        {
            var effectiveMastodonPostContextOptions = mastodonPostContextOptions ?? new MastodonPostContextOptions();

            if (effectiveMastodonPostContextOptions.IncludeAncestors)
            {
                post.Ancestors = GetAncestorPostIDs(post.Id).Select(BuildPost).ToList();
            }
            if (effectiveMastodonPostContextOptions.IncludeDescendants)
            {
                post.Descendants = GetDescendantPostID(post.Id).Select(BuildPost).ToList();
            }
            return(Task.CompletedTask);
        }
コード例 #2
0
        public async Task AddContextToMastodonPost(MastodonPost mastodonPost, MastodonPostContextOptions mastodonPostContextOptions = null)
        {
            var effectiveMastodonPostContextOptions = mastodonPostContextOptions ?? new MastodonPostContextOptions();
            var mastodonClient = GetOrCreateMastodonClient();

            if (effectiveMastodonPostContextOptions.IncludeAncestors || effectiveMastodonPostContextOptions.IncludeDescendants)
            {
                var statusContext = await mastodonClient.GetStatusContext(mastodonPost.Id.ToLong());
                if (effectiveMastodonPostContextOptions.IncludeAncestors)
                {
                    mastodonPost.Ancestors = statusContext.Ancestors.Select(s => s.ToPost()).ToList();
                }
                if (effectiveMastodonPostContextOptions.IncludeDescendants)
                {
                    mastodonPost.Descendants = statusContext.Descendants.Select(s => s.ToPost()).ToList();
                }
            }
        }