Notes - danopia/deviantart-difi GitHub Wiki

This class is used to interact with Notes (e.g. reading and sending Notes, starring a Note and marking Notes as "read" or "unread".)

create_folder

Creates a new folder for organizing notes.

Usage

  • When clicked on "New Folder" on the Notes page.

Params

  • foldername: string, defaults to "Devious Folder"
  • parentid: number, 0 for a root folder

Response

  • folderid: number, an id that is assigned to the new folder.
  • foldername: string, the name of the folder.

createWarningTemplate

Usage

Purpose unknown

Params

  • note_title: string
  • note_content: string

Response

undocumented

delete

Deletes a series of notes.

Usage

  • When one or more Note is selected and then the "Delete" button is clicked

Params

  • noteids: array of numbers, e.g. ["2103797848", "2106267368"].

Response

Returns an object with counts.1 containing the new amount of messages in the inbox, if applicable.

delete_folder

Deletes a custom folder, moving all messages inside to folder 1 (inbox).

Params

  • folderid: number.

Response

Returns an object repeating your folderid, and counts.1 containing the new amount of messages in the inbox, if applicable.

deleteWarningTemplate

undocumented

Params

  • templateid: number.

search

Searches Notes for a certain word or attribute.

Usage

  • When a query is entered into the search bar on the Notes page.

Params

  • query: string, search text (e.g. "foo")
  • from: array, containing usernames (e.g. ["spyed"])
  • to: array, containing matching recipients (e.g. ["jark"])
  • folders: array, containing matching folderids (e.g. ["106218"])
  • statuses: ???
  • offset: number, e.g. 25.

Response

Response is similar to display_folder.

display_folder

Loads a Notes folder.

Usage

  • When navigating Notes (e.g. opening a custom folder, or switching to the inbox).
  • When loading the initial Notes screen.
  • When deleting a note, which causes the Notes to reload.

Params

  • folderid: number/string, e.g. 0 for spam, 1 for inbox, 2 for sent, as well as strings such as 'starred', 'drafts', 'unread', or an integer folderid for custom folders.
  • offset: number, e.g. 0
  • deselectnote: boolean, e.g. true

TODO: Currently, it is unknown what purpose deselectnote does serve.

Response

Returns basic info. Resembles a Dialog but the content is in body instead of html.

{"html":null,
 "folderid":"1",
 "downloads":[],
 "title":null,
 "css":"",
 "deps":[],
 "dwaitcalls":[],
 "deselectnote":true,
 "pageData":[],
 "offset":0,
 "body":"    \n    <div class=\"h\" id=\"current-folder\"> . . . <\/div> <!-- #current-folder -->\n    "}

Javascript Example

var folder = 1, offset = 0;
DiFi.pushPost('Notes', 'display_folder', [folder,offset,true], function (success, data) {
    if (data.response.status == 'SUCCESS') {
        console.log(data.response.content.body);
    }
});
DiFi.send();

display_note

Returns the HTML view of a note.

Usage

  • When a Note is clicked on
  • On the initial page load

Params

  • folderid: number/string. (e.g. 0 for spam, 1 for inbox, 2 for sent.)
  • noteid: number, e.g. 2112292244

Response

  • On success, returns a two-field object:

    • noteid: your request note id

    • body: contains the HTML to view the note, e.g.:

      <div id="current-note"> . . . </div>

      Tip: To scrape for content, parse for the following elements:

      • span.mcb-title: note title
      • div.mcb-body wrap-text: html body
      • textarea.mcb-body: raw body
      • span.mcb-ts: note time (title has absolute time, content had relative time)
      • div.mcb-whoicon: contain's sender's username, avatar and profile link
  • On error:

    • error: "Could not load the note"

mark_as_read

Mark a series of notes as "read".

Params

  • noteids: array of numbers.

Response

Returns the array of note IDs in noteids and the new unread count in count.

mark_as_unread

Mark notes as "unread".

Params

  • noteids: array of numbers.

Response

Returns the array of note IDs in noteids and the new unread count in count.

move

Moves some notes to a new folder. Errors if they're already there, apparently.

Params

  • noteids: array of numbers.
  • folderid: number.

Response

Returns an object with as a key for every folder involved, with the new message counts as the values.

placebo_call

No-operation call. Used to make sure the user can send a note before he goes through the trouble of typing it all out.

Usage

  • Called when the "Send a Note" menu is clicked (on a user profile).

Params

None.

Response

Returns null on success.

preview

Previews a note's formatting, optionally including your signature.

Usage

  • When previewing a note.

Params

  • note: string
  • signature: boolean, includes your signature in the note

Response

Returns an HTML string.

Example

The request "Hey! :iconrickrollplz: :devart:",true returns the following:

    Hey! <a href="http://rickrollplz.deviantart.com/"><img class="avatar"
    src="http://a.deviantart.net/avatars/r/i/rickrollplz.gif?4"
    alt=":iconrickrollplz:" title="rickrollplz"/></a>
    <img src="http://e.deviantart.net/emoticons/d/devart.gif"
    width="32" height="17" alt=":devart:" title="deviantART"/><br /><br />--<br />
    Hackers are not criminals. Hackers are the only people out there to keep crackers and virus
    coders on the run. Hackers are misconstrued by the media, but in reality, they do not cause
    damage or steal. Hackers keep the Internet safe from those who don't.

(Like my sig?)

rename_folder

Renames an existing folder.

Params

  • folderid: number, the folder to rename
  • foldername: string, the new name

Response

Returns the foldername as well as a folderid.

save_draft

Saves a note in your drafts for later editing and sending.

Params

  • recipient: string, user to address to
  • subject: string, the note's title
  • body: string, the content
  • draftid: number, 0 to create a new draft, or a given id to update an existing draft

Response

  • On success, returns the noteid and the new count:
    • count: int, the number of new drafts
    • noteid: int, either the new draft id, or the updated draft id

star

Marks a series of notes as "starred".

Params

  • noteids: array of numbers.

Response

Returns the array of note IDs in noteids and the new starred count in count.

unstar

Marks a series of notes as "unstarred".

Params

  • noteids: array of numbers.

Response

Returns the array of note IDs in noteids and the new starred count in count.

updateWarningTemplate

Purpose unknown

Params

  • template_to_update: string
  • title: string
  • content: string

Response

undocumented

issueWarning

Purpose unknown

Usage

unknown

Params

  • username: string
  • item_type: number?
  • item_id: number
  • admin_id: number
  • message: string

Response

undocumented

move_note

Moves a single note?

Params

  • path: string (folder?)
  • messageid: number

delete_note

Deletes a single note?

Params

  • messageid: number

Response

undocumented

display_draft

Loads a draft note to display.

Usage

  • Called when browsing the draft notes.

Params

  • messageid: number

Response

  • On success:
    • noteid: number
    • subject: string
    • body: string
    • recipients: array containing usernames
  • On error:
    • error: "Could not load the draft"

display

Displays a note?

Params

  • messageid: number

Response

undocumented

show

undocumented

Usage

Purpose unknown

change_read_status

Changes the unread value for a single note.

Params

  • noteid: number, e.g. 2087135593
  • is_unread: boolean, i.e. false for not not read, true for read

Response

  • count: number of new unread notes, e.g. 7.
  • noteids: array containing the note ids.

change_starred

Changes the starred value of a series of notes.

Params

  • noteid: array containing ints, e.g. ["2087135593"]
  • is_starred: boolean, i.e. false for not starred, true for starred

Response

  • count: number, the count of new starred notes, e.g. 28.
  • noteids: array containing the note ids.

report_as_spam

Reports the note as spam. The spam flag cannot be removed even after the note is moved out of the spam folder, unless an administrator takes action.

Usage

  • Called when the user clicks on "Mark as... → Spam".

Params

  • noteid: array containing numbers, e.g. [2087135593]

Response

Returns an associative array with the new folder counts.

pimp

This method is used to send a deviation or share items (such as forum posts) to someone in a note.

Usage

  • When sharing a Deviation with someone.

Params

  • type: string (e.g. "deviation" or "forum")
  • itemid: number (e.g. post id, or deviation id)
  • username: string, the recipient username (e.g. "danopia")
  • message: string, the pimp message (e.g. "Check out this awesome deviation!")

NOTE: The note subject will be picked up from the item's title (e.g. the Deviation title), and the "pimped" item will be prepended to message in the note body.

Response

undocumented

valentine

Results in a "You've Received a Valentine!" Note for the recipient

Params

  • Used when sending Valentines Deviations to other Deviants.

Params

  • note_id: number?
  • username: string
  • message: string

Response

undocumented

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