Friends - danopia/deviantart-difi GitHub Wiki
This class is used to handle various devWATCH-related functions.
getFriendAttributesAndGroup
Returns a friendship's attributes.
Usage
- Called when opening the watch attributes dialog to modify a DeviantWATCH friendship.
Params
deviant_id
: integer
Response
-
On success, returns an object
e.g.:{"attributes":"11", "realname":"the Keepyr of Restaen Island", "lists":[], "groupid":"0"}
-
On fail, returns:
error
: This user was not found in your Watch list.
getFriendsMenu
Returns a list of everyone you're watching, including what group they're in, their userid, their symbol, their avatar type, and their last visit to the site (or Online/Invisible).
Usage
- Called when the "Friends" button is clicked in the menu bar.
Params
mode
: number:0
: watching,1
is for friends.- 0 for all users you're watching
- 1 to exclude anyone you haven't set as a "Friend" on the Deviants page.
page
: number, starting from 0.
Response
Returns the following on success:
-
has_more
: boolean, (e.g. true if more pages available) -
friends
: an array of friends, containing an object for each friend.username
: string, e.g. "danopia"symbol
: string, e.g. "~"realname
: string, the tagline of friendusericon
: number, types are denoted by integers:0
= none (using default)1
= GIF2
= JPG3
= PNG.
groupname
: string, i.e. what group they're inlastvisit
: string, their last visit time, e.g.: "4d 3m" can also be "Invisible" instead of a time string.groupid
: number, e.g. 0avatar
: string, complete url for the friend's avatar.
An avatar url looks like this:http://a.deviantart.com/avatars/e/t/etamart.png
when no avatar is set, default is used:http://a.deviantart.com/avatars/default.gif
Example friend object:
{"username":"Artfanatic4life", "symbol":"~", "usericon":"6", "realname":"xXColorzXx", "groupname":"", "groupid":null, "lastvisit":"3d 20h", "avatar":"http:\/\/a.deviantart.net\/avatars\/a\/r\/artfanatic4life.jpg?1"}
Javascript Example
var offset = 0;
GM_xmlhttpRequest({
method: 'GET',
url: "http://www.deviantart.com/global/difi.php?c[]=Friends;getFriendsMenu;0,"+offset+"&t=json",
onload: function (responseDetails) {
var data = JSON.parse("("+responseDetails.responseText+")");
console.log(data);
},
onerror:function(data){
console.log(data.responseText);
}
});
setAttributes
Updates a DeviantWATCH and/or friendship's attribute flags.
Usage
- Called when submitting the DeviantWATCH friendship status window.
- Called after modifying the watch items of a friendship window.
Params
deviant
: string (e.g. "DRSDavidSoft")flags
: number (e.g. 15 or 241), refer to Flags subsection
Response
Always returns null. Check for success with the response's status
field.
Flags
The flags
parameter is calculated by applying the bitwise OR operator to the v
attribute of each checkbox depending on the condition of the checked
state.
Checkbox | Value | Condition |
---|---|---|
Friend | 1 |
checked |
Deviations | 2 |
checked |
Scraps | 4 |
checked |
Journals, Polls and status updates | 8 |
checked |
Critiques | 16 |
un-checked |
Miscellaneous activity | 32 |
un-checked |
Forum Threads | 64 |
un-checked |
Collections | 128 |
un-checked |
NOTE: The value of some checkboxes (e.g. those above 16) are added on the opposite condition, meaning that their value should be added if they are unchcked. All other values should be added if their checkbox is checked.
Example
- Checking none of the checkboxes will result in
16
+32
+64
+128
=240
- Checking all of the checkboxes will result in
1
+2
+4
+8
=15
- Checking Friend, Scraps, Critiques and Forum Threads will result in
1
+4
+32
+128
=165
removeWatch
Removes a friend from the watch list.
Usage
unknown
Params
username
: string (e.g. "spyed")unwatch_bit
: number, what to unwatch (e.g.16
). Refer to watch flag bits.
Response
-
On success,
-
On fail:
error
: "Error"details
: "Bit not allowed"
removeWatchKeepMessages
Removes a friend from watch but keeps messages in center?
Usage
- In the Message Center?
Params
username
: string (e.g. "spyed")unwatch_bit
: number, what to unwatch (e.g.16
). Refer to watch flag bits.
Response
-
On success, returns null.
-
On fail:
error
: "Error"details
: "Bit not allowed"
removeAllMessages
Removes all messages by a watched user from the Message Center (i.e. notifications)
Usage
- When clicking "Remove all [message types] from [username]" in the MessageCenter's drop-down menu
Params
username
: string (e.g. "spyed")query
: number, what to remove (e.g.16
). Refer to watch flag bits.filter
: string, purpose unknown as of yet (e.g. "")
Response
-
On success, returns null.
-
On fail:
error
: "Error"details
: "Failed to remove messages"
Queries
Possible query
s (i.e. a watch flag, or a message type) are:
Name | Message Type devwatch&tg= |
Flag Bit | Constant |
---|---|---|---|
Deviations | deviations |
2 |
FRIEND_META_DEVS |
Scraps | depends | 4 |
FRIEND_META_SCRAPS |
Journals, Polls and status updates | journals , polls , status |
8 |
FRIEND_META_JOURNALS |
Critiques | critiques |
16 |
FRIEND_META_CRITIQUES |
Miscellaneous activity | activities |
32 |
FRIEND_META_ACTIVITY |
Forum Threads | forums |
64 |
FRIEND_META_FORUMS |
Refer to MessageCenter for more information.
Response
Returns null on success.
addFriend
REMOVED
Used to +devWATCH a user from the Deviations page
Usage
- After +faving several Deviations from an artist (that you weren't watching yet),
a modal used to appear that would call this method.
Params
username
: string, the person you watch???
: integer (e.g. 0)
addFriendGetAttributes
Adds a username to the watched users
Usage
- Called when watching a user using the one-click button
- Called when editing the watch settings on a user's page
Params
username
: string, the person you watchorigin
: string (e.g. "watch", "deviation", or "devwatch-editor" for one-click button)
The second parameter appears to indicate the originated source of watch.
Response
attributes
: int, the watch flag bits (e.g. 11)groupid
: number (e.g. 0)lists
: array (e.g. [])realname
: string (e.g. "Foo bar")was_watching
: boolean (e.g. false)
removeFriend
Unwatches the given username
Usage
unknown
Params
username
: string
Response
Returns null on success.
removeWatchAndFriend
Unwatches a certain username
Usage
- When clicked on "Unwatch" in the watch attributes modal
Params
username
: string
Response
Returns null on success.
getFriendsList
Returns a list of friends/watched users?
Usage
- Returns the list of 100 watched Deviants and Groups
Params
grouped
: boolean (i.e. true or false, true seems to expandgroupname
)currentPage
: id (i.e. "0", "1", "2" ... for the next n*100 watches)
Response
- On success, returns an array containing an object for each friend
groupid
: number, e.g. 0attributes
: number, e.g. 11username
: string, the watched usernamerealname
: string, the tagline for the watched usersymbol
: string, the user symbol (e.g.~
for normal users,#
for normal groups, etc)groupname
: string, e.g. "Unsorted"id
: number, the userid for the watched user or groupisagroup
: boolean (e.g. false if user, true if group)
getFriendsForLetter
This method is used to autocomplete usernames.
It seems that only the most relevant Deviants that begin with the letter are shown on dA, but this method returns all watched Deviants and Groups beginning with the letter.
Usage
- When mentioning a Deviant with @
- On the Notes search tool
Params
initial_letter
: stringletters_fetched
: int (or 0)
Response
friends
: An array containing the following objects:friendid
: int, the deviant id of the friendgroupid
: int, the shared group idattributes
: int, the "watch" flags (according to the setAttributes)username
: stringavatar
: string, the url of friend's profile imagerealname
: stringsymbol
: stringusericon
: int
has_more
: boolean (e.g. false)
Similar to the getFriendsMenu
response
unsuggest
Deletes watch suggestion?
Usage
- Most likely when clicking the 🗙 in the "Discover More Deviants To Watch!" widget in the Watch feed
Params
userid
: number
getWatchSuggestionsStream
Usage
Get new suggestion(s) in the "Discover More Deviants To Watch!" widget in the Watch feed.
Params
params
: objectoffset
: number, e.g. 6length
: number, e.g. 0mature_filter
: boolean, e.g. truepaging_mode
: string (e.g. "infinite")result_type
: string (e.g. "artists")thumb_mode
: string (e.g, "wall")view_mode
: string (e.g. "row")suggestion_type
: string (e.g. "home")suggestions_cursor
: array containing objects, e.g.source
: number, e.g. 1offset
: number, e.g. 1alive
: boolean, e.g. true
Example
{
"offset": "6",
"length": "6",
"mature_filter": true,
"paging_mode": "infinite",
"result_type": "artists",
"thumb_mode": "wall",
"view_mode": "row",
"suggestion_type": "home",
"suggestions_cursor": [{
"source": "1",
"offset": "1",
"alive": true
}, {
"source": "2",
"offset": "0",
"alive": true
}, {
"source": "4",
"offset": "5",
"alive": true
}, {
"source": "5",
"offset": "7",
"alive": true
}]
}
update_settings
undocumented
Usage
- Probably when editing and saving what to show in the Watch feed.
Params
settings
: object, calculated based on the.feed-settings-setting
element
Example: [{"1":"1","2":"1","4":"0","8":"0","16":"0","32":"0","64":"0","128":"0","256":"1"}]
addWatchPopulateMessages
undocumented
Usage
Unsure where this method is used
Params
userids
: array- ???: string (e.g. "watch")
Response
undocumented
unsubscribePromoted
undocumented
Params
None
Response
Returns null on success?
addToGroup
Usage
undocumented
Params
friendid
: number (e.g. "37591934")gid
: string, i.e. groupid (e.g. "0" for ungrouped, or "1836667" for the group id.)
Response
Always returns null. Check for success with the response's status
field.
addToNewGroup
undocumented
Params
friendid
: number (e.g. "37591934")new_group_name
: string (e.g. "Test Group")
Response
Always returns null. Check for success with the response's status
field.
getGroupOffset
Getting friends in a group of friends?
Params
groupid
: number
getFriendsCount
Returns the number of watched users?
Usage
Returns number of watches/friends. Very useful!
Params
None
Response
Count of friends
getAlphaGroupOffset
undocumented
Params
character
: string
setFriendAttributes
undocumented
Params
unsaved
: array, containing objectsid
: strings, same as checkboxid
attr
: number, same as watch flag bits