Comments - danopia/deviantart-difi GitHub Wiki

This class is used to interact with comments (such as posting, editing, viewing, etc) on the website.

post

Posts a comment on anything that can be commented on.

When replying to a comment, the typeid/itemid params still refer to the root object.

Usage

  • When submitting a new comment on anything, e.g. journals, deviations, profile pages, etc.
  • When replying to an existing comment.

Params

  • comment: string (e.g. "Hey, what's up? :P")
  • itemid: number, id of the object you're commenting on (e.g. "38345086")
  • parentid: number, 0 if no parent comment
  • typeid: string, type of the object you're commenting on (e.g. 4 for the profile page)
  • ownerid: number or 0

An extensive list of typeids is available in the Resource Types page.

Response

  • On success, an object is returned that includes an HTML version of the comment plus some info about it.
    This basically has enough information to display the stock HTML representation of the comment in the view.

    {"success":true,
     "body":"Hey, what's up? <img src=\"http:\/\/e.deviantart.net\/emoticons\/letters\/=p.gif\" width=\"15\" height=\"15\" alt=\":P\" title=\":P (Lick)\"\/>",
     "id":1865963218,
     "commentid":1865963218,
     "typeid":5,
     "itemid":38345086,
     "parentid":0,
     "velocity":false,
     "owner_userid":16076817,
     "ts":1297300063,
     "username":"danopia",
     "symbol":"~",
     "usericon":"10",
     "commentid":1865963218,
     "attributes":0,
     "mood":0,
     "html":"\n    <div class=\"ccomment ch\"  name=\"gmi-CComment\" id=\"gmi-CComment\" data-gmiclass=\"CComment\" 
             gmi-commentid=\"1865963218\" gmi-itemid=\"38345086\" gmi-typeid=\"5\" gmi-private=\"0\" gmi-hidemoods=\"1\" 
             gmi-allowdrawings=\"1\" gmi-splitid=\"16076817\"> . . . <\/div>"}
  • On fail, possible returns are:

    • error: "The user you are commenting on has deactivated their account."

preview

Previews a comment while typing them, parses all formatting into HTML.

Usage

  • When previewing a comment.

Params

  • TextToSave: string (e.g. "Hey, what's up? :P")
  • previewHasThumbs: number (e.g. "1")

Response

Returns a simple string with the HTML version of the comment.

Example:

"Hey, what's up? <img src=\"http:\/\/e.deviantart.net\/emoticons\/letters\/=p.gif\" width=\"15\" height=\"15\" alt=\":P\" title=\":P (Lick)\"\/>"

preview_v2

Previews a comment, parsing all formatting into HTML, new dA call.

Usage

  • When previewing a comment.

Params

  • TextToSave: string (e.g. "Hey, what's up? :P")
  • previewHasThumbs: boolean, e.g. "1"
  • typeid: number, e.g. "1"
  • itemid: number, e.g. "426223868"

NOTE: previewHasThums refer to whether this type of comment allows for thumbnails in previews.

Response

Returns a simple string with the HTML version of the comment.

Javascript Example

This is an example from dAhub Contest widget that utilizes the DiFi object:

DiFi.pushPost("Comments","preview_v2",[zwiicon,"1","1","426223868"],function(success, data){
    var imgrex=/<a (?:[^>]*?)><img (?:[^>]*?)><\/a>/gi;
    var iconlist=data.response.content.match(imgrex);
    $("<div id='dahub_icon_temp'>").attr("data",JSON.stringify(iconlist)).appendTo($("body"));
    $("#dAhub_CM_Tab.selected").click();
});
DiFi.send();

getBodies

REMOVED – This call seems to have been removed and not used anymore.

Returns HTML text and signature of the specified comment

Usage

  • When viewing a comment?

Params

  • comment_id: number
  • type_id: number
  • item_id: number
  • user_id: number (for sig)

Response

Returns the comment in HTML

  • text: the comment body
  • signature: the user's signature (defaults to null)

getParent

Returns the instance for the parent comment of a reply in the Message Center.

Usage

  • When the view "Original" button on a comment is clicked

Params

  • item_id: number, the object which the comment is made on
  • comment_id: number, the comment id

Response

  • On success, returns:
    • commentid: number, the comment id
    • parentid: number, the parent comment id
    • typeid: number, the resource type id of the item
    • itemid: number, the object id which the comment is made on
    • attributes: number, ??? (e.g. 0)
    • userid: number, the user id of the commenter
    • ts: number, the creation timestamp of the comment
    • edit_ts: number, the edit timestamp, or 0 if none
    • replies: number, the number of replies to the parent
    • like_counter: number, ???
    • username: string, the username of the commenter
    • usericon: number, refer to the User class
    • symbol: string, e.g. ~
    • joindate: number, the timestamp of the comment's join date
    • extra: object:
      • specialty: number (e.g. 0)
      • skill_level: number (e.g. 0)
      • user_type: number (e.g. 1)
    • body: string, the content of the comment

NOTE: This method will return the instance for the parent comment.
This means that commentid will refer to the parent comment, and parentid refers to its parent respectively.

  • On fail, you will get a generic DiFi error.

getArtistComment

REMOVED Grabs the artist comment for a deviation

Params

  • deviation_id: number

getThread

REMOVED Grabs thread

Params

  • typeid: number
  • item_id: number (item id of thread you want)
  • unknown: number

post_from_messagecenter

Posts a reply to a comment that appeared in the MessageCenter (i.e. Notifications).
The method can be used to remove the comment from message center if the reply is posted to it.

Also see Comments::post method.

Usage

  • When replying to a comment that appeared in the Message Center.

Params

  • comment: string (e.g. "Hey, what's up? :P")
  • itemid: number, id of the object you're replying on (e.g. "503742212")
  • parentid: number, id of the parent comment you're replying to
  • typeid: number, the resource type of the object you're replying on, see Resource Types
  • ownerid: number, e.g. 0
  • remove_message_after_reply: number,
    if ture removes the corresponding message from message center after the reply to the parent comment is posted.
    (1 if checked, 0 if not checked)

Response

See Comments::post method.

getThreadRange

Returns comments on an object. Very useful!

Usage

Unknown at this moment

Params

  • itemid: id
  • typeid: id
  • offset: int (e.g. 0)
  • limit: int (e.g. 20)

Response

  • On success:
    • thread: contains array of objects
      Refer to getParent method for example of a comment object
    • threadinfo: object
      • hide: number, ???, e.g. 4
      • master: boolean, ???, e.g. false
      • offset: number, ???, e.g. 0
      • maxlevel: number, ???, e.g. 7
      • typeid: number, the resource type id
      • order: number, ???, e.g. 2
      • limit: number, equal to the count_per_page parameter
      • itemid: number
      • limitgood: number, ??? same as limit?
      • usericonurl: boolean, ???, true
      • splitid: purpose unknown
      • length: number, number of all comments on the thread?
      • moreleft: boolean, means if more comments on the next page are available
      • lessleft: boolean, means if more comments on the previous page are available
      • next_offset:
      • prev_offset:
      • thread_flat: object, contains a list of all comments on the thread, with comment ids as keys and the reply counts as each value.

edit

Edits and already posted comment

Usage

  • When editing a comment

Params

  • TextToSave: string (e.g. "Hey, what's up? :P")
  • itemid: number
  • parentid: number or 0
  • typeid: number

Response

undocumented

filmPost

undocumented, almost definitely for posts on films, especially when commenting while the film is playing

Params

  • TextToSave: string (e.g. "Hey, what's up? :P")
  • itemid: number
  • parentid: number or 0
  • typeid: number
  • ownerid: number or 0
  • time_index: number or 0

getTemplates

REMOVED

getEditBody

Returns body of a comment in the edit field?

Usage

  • When trying to edit a comment

Params

  • itemid: int
  • commentid: int
  • typeid: int

Response

On success, returns string.

getLimitedComments

Returns the html required to build the top comments on any object?

TODO: What exactly is limited?

Params

  • typeid: number (e.g. 1 for COMMENT_DEVIATION)
  • itemid: number
  • ???: number (e.g. 0)
  • offset: int (e.g. 0)
  • limit: int (limit+1 so we can see if there are more to fetch)

Response

Returns a Dialog object, with html containing complete html for the selected range.

getAnnotations

Seems to return form with how to display the comments (Nested/Threaded/Flat, Oldest First/Newest First).

Usage

Params

  • comment_typeid: int
  • deviationid: int
  • time_index_beg: int
  • time_index_end: int
  • offset: int

Response

⚠️ **GitHub.com Fallback** ⚠️