/// <summary>
 /// Resets the subreddit's header image to the Reddit logo
 /// </summary>
 public async Task ResetHeaderImage()
 {
     await WebAgent.Post(DeleteHeaderImageUrl, new
     {
         r = Subreddit.Name
     }).ConfigureAwait(false);
 }
Exemple #2
0
 /// <summary>
 /// Set the page editor for a given page.
 /// </summary>
 /// <param name="page">wiki page</param>
 /// <param name="username"></param>
 /// <param name="allow"></param>
 public async Task SetPageEditorAsync(string page, string username, bool allow)
 {
     await WebAgent.Post(allow?WikiPageAllowEditorAddUrl : WikiPageAllowEditorDelUrl, new
     {
         page     = page,
         username = username
     }).ConfigureAwait(false);
 }
Exemple #3
0
 /// <summary>
 /// Revert a page to a specific version.
 /// </summary>
 /// <param name="page">wiki page</param>
 /// <param name="revision">page version</param>
 public async Task RevertPageAsync(string page, string revision)
 {
     await WebAgent.Post(RevertWikiPageUrl, new
     {
         page     = page,
         revision = revision
     }).ConfigureAwait(false);
 }
Exemple #4
0
 /// <summary>
 /// Set settings for the specified wiki page.
 /// </summary>
 /// <param name="name">wiki page</param>
 /// <param name="listed">public listing or not</param>
 /// <param name="editMode"><see cref="WikiPageSettings.WikiPagePermissionLevel"/>editing permissions</param>
 public async Task SetPageSettingsAsync(string name, bool listed, WikiPageSettings.WikiPagePermissionLevel editMode)
 {
     await WebAgent.Post(WikiPageSettingsUrl(name), new
     {
         page      = name,
         permlevel = (int)editMode,
         listed    = listed
     }).ConfigureAwait(false);
 }
Exemple #5
0
 /// <summary>
 /// Update the css.
 /// </summary>
 public async Task UpdateCssAsync()
 {
     await WebAgent.Post(UpdateCssUrl, new
     {
         op = "save",
         stylesheet_contents = CSS,
         api_type            = "json",
         r = Subreddit.Name
     }).ConfigureAwait(false);
 }
        /// <summary>
        /// Delete this subreddit image.
        /// </summary>
        /// <returns></returns>
        public async Task DeleteAsync()
        {
            await WebAgent.Post(DeleteImageUrl, new
            {
                img_name = Name,
                r        = SubredditStyle.Subreddit.Name
            }).ConfigureAwait(false);

            SubredditStyle.Images.Remove(this);
        }
Exemple #7
0
        /// <summary>
        /// Edit a wiki page.
        /// </summary>
        /// <param name="page">wiki page</param>
        /// <param name="content">new content</param>
        /// <param name="previous">previous</param>
        /// <param name="reason">reason for edit</param>
        public async Task EditPageAsync(string page, string content, string previous = null, string reason = null)
        {
            dynamic param = new
            {
                content = content,
                page    = page
            };
            List <string> addParams = new List <string>();

            if (previous != null)
            {
                addParams.Add("previous");
                addParams.Add(previous);
            }
            if (reason != null)
            {
                addParams.Add("reason");
                addParams.Add(reason);
            }
            await WebAgent.Post(WikiPageEditUrl, param, addParams.ToArray()).ConfigureAwait(false);
        }
        /// <summary>
        /// Update the subreddit settings.
        /// </summary>
        public async Task UpdateSettings()
        {
            string link_type;
            string type;
            string wikimode;

            switch (ContentOptions)
            {
            case ContentOptions.All:
                link_type = "any";
                break;

            case ContentOptions.LinkOnly:
                link_type = "link";
                break;

            default:
                link_type = "self";
                break;
            }
            switch (SubredditType)
            {
            case SubredditType.Archived:
                type = "archived";
                break;

            case SubredditType.EmployeesOnly:
                type = "employees_only";
                break;

            case SubredditType.GoldOnly:
                type = "gold_only";
                break;

            case SubredditType.GoldRestricted:
                type = "gold_restricted";
                break;

            case SubredditType.Private:
                type = "private";
                break;

            case SubredditType.Public:
                type = "public";
                break;

            case SubredditType.Restricted:
                type = "restricted";
                break;

            case SubredditType.User:
                type = "user";
                break;

            default:
                type = "public";
                break;
            }
            switch (WikiEditMode)
            {
            case WikiEditMode.All:
                wikimode = "anyone";
                break;

            case WikiEditMode.Moderators:
                wikimode = "modonly";
                break;

            default:
                wikimode = "disabled";
                break;
            }
            await WebAgent.Post(SiteAdminUrl, new
            {
                allow_top    = AllowAsDefault,
                allow_images = AllowImages,
                description  = Sidebar,
                domain       = Domain,
                lang         = Language,
                link_type,
                over18             = NSFW,
                public_description = PublicDescription,
                show_media         = ShowThumbnails,
                sr    = Subreddit.FullName,
                title = Title,
                type,
                wiki_edit_age   = WikiEditAge,
                wiki_edit_karma = WikiEditKarma,
                wikimode,
                spam_links     = SpamFilter?.LinkPostStrength.ToString().ToLowerInvariant(),
                spam_selfposts = SpamFilter?.SelfPostStrength.ToString().ToLowerInvariant(),
                spam_comments  = SpamFilter?.CommentStrength.ToString().ToLowerInvariant(),
                api_type       = "json"
            }, "header-title", HeaderHoverText).ConfigureAwait(false);
        }