示例#1
0
        public UserTemplate(SporeServerUser author, SporeServerAsset[] assets)
        {
            // <feed />
            //
            var document = AtomFeedBuilder.CreateDocument("feed");

            // <id />
            AtomFeedBuilder.AddCustomElement(document, "id", $"tag:spore.com,2006:user/{author.Id}");
            // <title />
            AtomFeedBuilder.AddCustomElement(document, "title", $"{author.UserName}");
            // <updated />
            // TODO
            AtomFeedBuilder.AddCustomElement(document, "updated", $"{XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Utc)}");
            // <author />
            AtomFeedBuilder.AddAuthorElement(document, $"{author.UserName}", $"{author.Id}");
            // <subcount />
            // TODO?
            AtomFeedBuilder.AddCustomElement(document, "subcount", "0");
            // <link />
            AtomFeedBuilder.AddLinkElement(document, "self", $"https://pollinator.spore.com/pollinator/atom/user/{author.Id}", null, null);

            // add assets to feed
            SporeAtomFeedHelper.AddAssetsToFeed(document, assets);

            // save xml
            _xml = document.OuterXml;
        }
示例#2
0
        public AggregatorTemplate(SporeServerAggregator aggregator, int subscriberCount)
        {
            // <feed />
            //
            var document = AtomFeedBuilder.CreateDocument("feed");

            // <id />
            AtomFeedBuilder.AddCustomElement(document, "id", $"tag:spore.com,2006:aggregator/{aggregator.AggregatorId}");
            // <title />
            AtomFeedBuilder.AddCustomElement(document, "title", $"{aggregator.Name}");
            // <updated />
            AtomFeedBuilder.AddCustomElement(document, "updated", $"{XmlConvert.ToString(aggregator.Timestamp, XmlDateTimeSerializationMode.Utc)}");
            // <subtitle />
            AtomFeedBuilder.AddCustomElement(document, "subtitle", $"{aggregator.Description}");
            // <author />
            AtomFeedBuilder.AddAuthorElement(document, $"{aggregator.Author.UserName}", $"{aggregator.Author.Id}");
            // <subcount />
            AtomFeedBuilder.AddCustomElement(document, "subcount", $"{subscriberCount}");
            // <link />
            AtomFeedBuilder.AddLinkElement(document, "self", $"https://www.spore.com/pollinator/atom/aggregator/{aggregator.AggregatorId}", null, null);

            // add assets to feed
            SporeAtomFeedHelper.AddAssetsToFeed(document, aggregator.Assets.ToArray());

            // save xml
            _xml = document.OuterXml;
        }
        public RandomAssetTemplate(SporeServerAsset[] assets)
        {
            // <feed />
            //
            var document = AtomFeedBuilder.CreateDocument("feed");

            // <id />
            AtomFeedBuilder.AddCustomElement(document, "id", "tag:spore.com,2006:randomAsset");
            // <title />
            AtomFeedBuilder.AddCustomElement(document, "title", "randomAsset");
            // <updated />
            AtomFeedBuilder.AddCustomElement(document, "updated", $"{XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Utc)}");
            // <link />
            AtomFeedBuilder.AddLinkElement(document, "self", "https://pollinator.spore.com/pollinator/atom/randomAsset", null, null);

            // add assets to feed
            SporeAtomFeedHelper.AddAssetsToFeed(document, assets);

            // save xml
            _xml = document.OuterXml;
        }
        public HandshakeTemplate(SporeServerUser user, SporeServerAggregator[] aggregators, Int32[] aggregatorSubscriptionCounts, SporeServerUserSubscription[] userSubscriptions, SporeServerAggregatorSubscription[] aggregatorSubscriptions)
        {
            // <handshake />
            //
            var document = AtomFeedBuilder.CreateDocument("handshake");

            // <user-id />
            AtomFeedBuilder.AddCustomElement(document, "user-id", $"{user.Id}");
            // <screen-name />
            AtomFeedBuilder.AddCustomElement(document, "screen-name", $"{user.UserName}");
            // <next-id />
            AtomFeedBuilder.AddCustomElement(document, "next-id", $"{user.NextAssetId}");
            // <refresh-rate />
            AtomFeedBuilder.AddCustomElement(document, "refresh-rate", "120");

            // <maxis-feeds />
            //
            AtomFeedBuilder.AddCustomElement(document, "maxis-feeds");

            /* We can remove this because
             * the official server returns an empty feed at the url anyways
             * maybe allow custom sporecasts here in the future?
             * AtomFeedBuilder.AddFeedEntry(document, maxisFeeds,
             *  id: "tag:spore.com,2006:maxis/adventures/en_US",
             *  title: "Maxis Adventures",
             *  updated: DateTime.Now,
             *  subtitle: "Free creations from Maxis.",
             *  authorName: null,
             *  authorUri: null,
             *  subCount: 0,
             *  link: "https://pollinator.spore.com/pollinator/atom/maxis/adventures/en_US");
             */

            // <my-feeds />
            //
            var myFeeds = AtomFeedBuilder.AddCustomElement(document, "my-feeds");

            for (int i = 0; i < aggregators.Length; i++)
            {
                var aggregator = aggregators[i];
                var aggregatorSubscriptionCount = aggregatorSubscriptionCounts[i];
                AtomFeedBuilder.AddFeedEntry(document, myFeeds,
                                             id: $"tag:spore.com,2006:aggregator/{aggregator.AggregatorId}",
                                             title: $"{aggregator.Name}",
                                             updated: DateTime.Now,
                                             subtitle: null,
                                             authorName: $"{aggregator.Author.UserName}",
                                             authorUri: $"{aggregator.AuthorId}",
                                             subCount: aggregatorSubscriptionCount,
                                             link: $"https://pollinator.spore.com/pollinator/atom/aggregator/{aggregator.AggregatorId}");
            }
            AtomFeedBuilder.AddFeedEntry(document, myFeeds,
                                         id: $"tag:spore.com,2006:user/{user.Id}",
                                         title: $"{user.UserName}",
                                         updated: DateTime.Now,
                                         subtitle: null,
                                         authorName: $"{user.UserName}",
                                         authorUri: $"{user.Id}",
                                         subCount: 0,
                                         link: $"https://pollinator.spore.com/pollinator/atom/user/{user.Id}");

            // <subscriptions />
            //
            var subscriptionsFeed = AtomFeedBuilder.AddCustomElement(document, "subscriptions");

            foreach (var subscription in userSubscriptions)
            {
                AtomFeedBuilder.AddFeedEntry(document, subscriptionsFeed,
                                             id: $"tag:spore.com,2006:user/{subscription.UserId}",
                                             title: $"{subscription.User.UserName}",
                                             updated: DateTime.Now,
                                             subtitle: null,
                                             authorName: $"{subscription.User.UserName}",
                                             authorUri: $"{subscription.UserId}",
                                             subCount: 0,
                                             link: $"https://pollinator.spore.com/pollinator/atom/user/{subscription.UserId}");
            }
            foreach (var subscription in aggregatorSubscriptions)
            {
                AtomFeedBuilder.AddFeedEntry(document, subscriptionsFeed,
                                             id: $"tag:spore.com,2006:aggregator/{subscription.AggregatorId}",
                                             title: $"{subscription.Aggregator.Name}",
                                             updated: subscription.Aggregator.Timestamp,
                                             subtitle: $"{subscription.Aggregator.Description}",
                                             authorName: $"{subscription.Aggregator.Author.UserName}",
                                             authorUri: $"{subscription.Aggregator.AuthorId}",
                                             subCount: 0,
                                             link: $"https://pollinator.spore.com/pollinator/atom/aggregator/{subscription.AggregatorId}");
            }

            // <invisible-feeds />
            //
            var invisibleFeed = AtomFeedBuilder.AddCustomElement(document, "invisible-feeds");

            AtomFeedBuilder.AddFeedEntry(document, invisibleFeed,
                                         id: "tag:spore.com,2006:downloadQueue",
                                         title: $"{user.UserName}",
                                         updated: DateTime.Now,
                                         subtitle: null,
                                         authorName: $"{user.UserName}",
                                         authorUri: $"{user.Id}",
                                         subCount: 0,
                                         link: "https://pollinator.spore.com/pollinator/atom/downloadQueue");

            // save xml
            _xml = document.OuterXml;
        }