mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
1 line
53 KiB
Plaintext
1 line
53 KiB
Plaintext
{"version":3,"sources":["../src/message_repository.js"],"names":["define","$","Ajax","Notification","Constants","CONVERSATION_TYPES","sendMessagesToUser","toUserId","messages","formattedMessages","map","message","touserid","text","call","methodname","args","then","results","errors","reduce","carry","result","errormessage","push","length","Error","join","id","msgid","timecreated","useridfrom","conversationid","candeletemessagesforallusers","sendMessagesToConversation","conversationId","countUnreadConversations","promise","fail","exception","getContacts","userId","limit","offset","userid","limitnum","limitfrom","blockUser","blockedUserId","when","apply","blockeduserid","referenceuserid","userids","includecontactrequests","includeprivacyinfo","reponse1","profiles","unblockUser","unblockedUserId","unblockeduserid","createContactRequest","requestUserIds","requesteduserid","deleteContacts","contactUserIds","response1","getMessages","currentUserId","newestFirst","timeFrom","currentuserid","convid","newest","timefrom","searchUsers","searchString","search","searchMessages","sendMessageToUser","sendMessageToConversation","savePreferences","preferences","getPreferences","deleteMessages","messageIds","messageId","messageid","deleteMessagesForAllUsers","deleteConversation","conversationids","getContactRequests","acceptContactRequest","sendingUserId","recipientUserId","declineContactRequest","getConversation","loggedInUserId","includeContactRequests","includePrivacyInfo","memberLimit","memberOffset","messageLimit","messageOffset","newestMessagesFirst","memberlimit","memberoffset","messagelimit","messageoffset","newestmessagesfirst","getConversationBetweenUsers","otherUserId","otheruserid","getSelfConversation","getConversations","type","favourites","mergeself","conversations","conversation","PRIVATE","SELF","otherUser","members","name","fullname","imageurl","profileimageurl","getConversationMembers","setFavouriteConversations","conversationIds","setMutedConversations","unsetFavouriteConversations","unsetMutedConversations","getMemberInfo","referenceUserId","userIds","markAllConversationMessagesAsRead","getUserMessagePreferences","getTotalConversationCounts","getUnreadConversationCounts","getAllConversationCounts","total","unread"],"mappings":"AAwBAA,OAAM,mCACN,CACI,QADJ,CAEI,WAFJ,CAGI,mBAHJ,CAII,yDAJJ,CADM,CAMH,SACCC,CADD,CAECC,CAFD,CAGC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M,CAAEH,CADN,CAFV,CADW,CAOX,CACI1B,UAAU,CAAE,6CADhB,CAEIC,IAAI,CAAE,CACF4B,MAAM,CAAEH,CADN,CAFV,CAPW,CAcW,CAAnB,EAAwCxB,IAAxC,CAA6C,SAAS6H,CAAT,CAAgBC,CAAhB,CAAwB,CACxE,MAAO,CACHD,KAAK,CAAEA,CADJ,CAEHC,MAAM,CAAEA,CAFL,CAIV,CALM,CAMV,CAEM,CAsCV,CAljCK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Retrieves messages from the server.\n *\n * @module core_message/message_repository\n * @class message_repository\n * @package message\n * @copyright 2016 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core_message/message_drawer_view_conversation_constants'\n], function(\n $,\n Ajax,\n Notification,\n Constants) {\n\n var CONVERSATION_TYPES = Constants.CONVERSATION_TYPES;\n\n /**\n * Count the number of unread conversations (one or more messages from a user)\n * for a given user.\n *\n * @param {object} args The request arguments:\n * @return {object} jQuery promise\n */\n var countUnreadConversations = function(args) {\n var request = {\n methodname: 'core_message_get_unread_conversations_count',\n args: args\n };\n\n var promise = Ajax.call([request])[0];\n\n promise.fail(Notification.exception);\n\n return promise;\n };\n\n /**\n * Get contacts for given user.\n *\n * @param {int} userId The user id\n * @param {int} limit Limit for results\n * @param {int} offset Offset for results\n * @return {object} jQuery promise\n */\n var getContacts = function(userId, limit, offset) {\n var args = {\n userid: userId\n };\n\n if (typeof limit !== 'undefined') {\n args.limitnum = limit;\n }\n\n if (typeof offset !== 'undefined') {\n args.limitfrom = offset;\n }\n\n var request = {\n methodname: 'core_message_get_user_contacts',\n args: args\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Block a user.\n *\n * @param {int} userId The requesting user\n * @param {int} blockedUserId Id of user to block\n * @return {object} jQuery promise\n */\n var blockUser = function(userId, blockedUserId) {\n var requests = [\n {\n methodname: 'core_message_block_user',\n args: {\n userid: userId,\n blockeduserid: blockedUserId\n }\n },\n {\n methodname: 'core_message_get_member_info',\n args: {\n referenceuserid: userId,\n userids: [blockedUserId],\n includecontactrequests: true,\n includeprivacyinfo: true\n }\n }\n ];\n\n // Wrap both requests in a single promise so that we can catch an error\n // from either request.\n return $.when.apply(null, Ajax.call(requests)).then(function(reponse1, profiles) {\n // Only return the profile.\n return profiles.length ? profiles[0] : {};\n });\n };\n\n /**\n * Unblock a user.\n *\n * @param {int} userId The requesting user\n * @param {int} unblockedUserId Id of user to unblock\n * @return {object} jQuery promise\n */\n var unblockUser = function(userId, unblockedUserId) {\n var requests = [\n {\n methodname: 'core_message_unblock_user',\n args: {\n userid: userId,\n unblockeduserid: unblockedUserId\n }\n },\n {\n methodname: 'core_message_get_member_info',\n args: {\n referenceuserid: userId,\n userids: [unblockedUserId],\n includecontactrequests: true,\n includeprivacyinfo: true\n }\n }\n ];\n\n // Wrap both requests in a single promise so that we can catch an error\n // from either request.\n return $.when.apply(null, Ajax.call(requests)).then(function(reponse1, profiles) {\n // Only return the profile.\n return profiles.length ? profiles[0] : {};\n });\n };\n\n /**\n * Create a request to add a user as a contact.\n *\n * @param {int} userId The requesting user\n * @param {int[]} requestUserIds List of user ids to add\n * @return {object} jQuery promise\n */\n var createContactRequest = function(userId, requestUserIds) {\n var request = {\n methodname: 'core_message_create_contact_request',\n args: {\n userid: userId,\n requesteduserid: requestUserIds\n }\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Remove a list of users as contacts.\n *\n * @param {int} userId The requesting user\n * @param {int[]} contactUserIds List of user ids to add\n * @return {object} jQuery promise\n */\n var deleteContacts = function(userId, contactUserIds) {\n var requests = [\n {\n methodname: 'core_message_delete_contacts',\n args: {\n userid: userId,\n userids: contactUserIds\n }\n },\n {\n methodname: 'core_message_get_member_info',\n args: {\n referenceuserid: userId,\n userids: contactUserIds,\n includecontactrequests: true,\n includeprivacyinfo: true\n }\n }\n ];\n\n return $.when.apply(null, Ajax.call(requests)).then(function(response1, profiles) {\n // Return all of the profiles as an array.\n return profiles;\n });\n };\n\n /**\n * Get messages between two users.\n *\n * @param {int} currentUserId The requesting user\n * @param {int} conversationId Other user in the conversation\n * @param {int} limit Limit for results\n * @param {int} offset Offset for results\n * @param {bool} newestFirst Order results by newest first\n * @param {int} timeFrom Only return messages after this timestamp\n * @return {object} jQuery promise\n */\n var getMessages = function(currentUserId, conversationId, limit, offset, newestFirst, timeFrom) {\n var args = {\n currentuserid: currentUserId,\n convid: conversationId,\n newest: newestFirst ? true : false\n };\n\n if (typeof limit !== 'undefined') {\n args.limitnum = limit;\n }\n\n if (typeof offset !== 'undefined') {\n args.limitfrom = offset;\n }\n\n if (typeof timeFrom !== 'undefined') {\n args.timefrom = timeFrom;\n }\n\n var request = {\n methodname: 'core_message_get_conversation_messages',\n args: args\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Search for users.\n *\n * @param {int} userId The requesting user\n * @param {string} searchString Search string\n * @param {int} limit Limit for results\n * @param {int} offset Offset for results\n * @return {object} jQuery promise\n */\n var searchUsers = function(userId, searchString, limit, offset) {\n var args = {\n userid: userId,\n search: searchString\n };\n\n if (typeof limit !== 'undefined') {\n args.limitnum = limit;\n }\n\n if (typeof offset !== 'undefined') {\n args.limitfrom = offset;\n }\n\n var request = {\n methodname: 'core_message_message_search_users',\n args: args\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Search for messages.\n *\n * @param {int} userId The requesting user\n * @param {string} searchString Search string\n * @param {int} limit Limit for results\n * @param {int} offset Offset for results\n * @return {object} jQuery promise\n */\n var searchMessages = function(userId, searchString, limit, offset) {\n var args = {\n userid: userId,\n search: searchString\n };\n\n if (typeof limit !== 'undefined') {\n args.limitnum = limit;\n }\n\n if (typeof offset !== 'undefined') {\n args.limitfrom = offset;\n }\n\n var request = {\n methodname: 'core_message_data_for_messagearea_search_messages',\n args: args\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Send a list of messages to a user.\n *\n * @param {int} toUserId The recipient user id\n * @param {string[]} messages List of messages to send\n * @return {object} jQuery promise\n */\n var sendMessagesToUser = function(toUserId, messages) {\n var formattedMessages = messages.map(function(message) {\n return {\n touserid: toUserId,\n text: message\n };\n });\n var request = {\n methodname: 'core_message_send_instant_messages',\n args: {\n messages: formattedMessages\n }\n };\n\n return Ajax.call([request])[0]\n .then(function(results) {\n // Error handling for the weird way the old function works.\n var errors = results.reduce(function(carry, result) {\n if (result.errormessage) {\n carry.push(result.errormessage);\n }\n\n return carry;\n }, []);\n if (errors.length) {\n throw new Error(errors.join(\"\\n\"));\n }\n\n return results;\n })\n .then(function(results) {\n // Format the results to match the other send message function.\n return results.map(function(result) {\n return {\n id: result.msgid,\n text: result.text,\n timecreated: result.timecreated,\n useridfrom: result.useridfrom,\n conversationid: result.conversationid,\n candeletemessagesforallusers: result.candeletemessagesforallusers\n };\n });\n });\n };\n\n /**\n * Send a single message to a user.\n *\n * @param {int} toUserId The recipient user id\n * @param {string} text The message text\n * @return {object} jQuery promise\n */\n var sendMessageToUser = function(toUserId, text) {\n return sendMessagesToUser(toUserId, [text])\n .then(function(results) {\n return results[0];\n });\n };\n\n /**\n * Send messages to a conversation.\n *\n * @param {int} conversationId The conversation id\n * @param {string[]} messages List of messages to send\n * @return {object} jQuery promise\n */\n var sendMessagesToConversation = function(conversationId, messages) {\n var formattedMessages = messages.map(function(message) {\n return {\n text: message\n };\n });\n var request = {\n methodname: 'core_message_send_messages_to_conversation',\n args: {\n conversationid: conversationId,\n messages: formattedMessages\n }\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Send a message to a conversation.\n *\n * @param {int} conversationId The conversation id\n * @param {string} text The message text\n * @return {object} jQuery promise\n */\n var sendMessageToConversation = function(conversationId, text) {\n return sendMessagesToConversation(conversationId, [text])\n .then(function(result) {\n return result[0];\n });\n };\n\n /**\n * Save message preferences.\n *\n * @param {int} userId The owner of the preferences\n * @param {object[]} preferences New preferences values\n * @return {object} jQuery promise\n */\n var savePreferences = function(userId, preferences) {\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n userid: userId,\n preferences: preferences\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Get the user's preferences.\n *\n * @param {int} userId The target user\n * @return {object} jQuery promise\n */\n var getPreferences = function(userId) {\n var request = {\n methodname: 'core_user_get_user_preferences',\n args: {\n userid: userId\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Delete a list of messages.\n *\n * @param {int} userId The user to delete messages for\n * @param {int[]} messageIds List of message ids to delete\n * @return {object} jQuery promise\n */\n var deleteMessages = function(userId, messageIds) {\n return $.when.apply(null, Ajax.call(messageIds.map(function(messageId) {\n return {\n methodname: 'core_message_delete_message',\n args: {\n messageid: messageId,\n userid: userId\n }\n };\n })));\n };\n\n /**\n * Delete a list of messages for all users.\n *\n * @param {int} userId The user to delete messages for\n * @param {int[]} messageIds List of message ids to delete\n * @return {object} jQuery promise\n */\n var deleteMessagesForAllUsers = function(userId, messageIds) {\n return $.when.apply(null, Ajax.call(messageIds.map(function(messageId) {\n return {\n methodname: 'core_message_delete_message_for_all_users',\n args: {\n messageid: messageId,\n userid: userId\n }\n };\n })));\n };\n\n /**\n * Delete a conversation between two users.\n *\n * @param {int} userId The user to delete messages for\n * @param {int} conversationId The id of the conversation\n * @return {object} jQuery promise\n */\n var deleteConversation = function(userId, conversationId) {\n var request = {\n methodname: 'core_message_delete_conversations_by_id',\n args: {\n userid: userId,\n conversationids: [conversationId]\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Get the list of contact requests for a user.\n *\n * @param {int} userId The user id\n * @return {object} jQuery promise\n */\n var getContactRequests = function(userId) {\n var request = {\n methodname: 'core_message_get_contact_requests',\n args: {\n userid: userId\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Accept a contact request.\n *\n * @param {int} sendingUserId The user that sent the request\n * @param {int} recipientUserId The user that received the request\n * @return {object} jQuery promise\n */\n var acceptContactRequest = function(sendingUserId, recipientUserId) {\n var requests = [\n {\n methodname: 'core_message_confirm_contact_request',\n args: {\n userid: sendingUserId,\n requesteduserid: recipientUserId\n }\n },\n {\n methodname: 'core_message_get_member_info',\n args: {\n referenceuserid: recipientUserId,\n userids: [sendingUserId],\n includecontactrequests: true,\n includeprivacyinfo: true\n }\n }\n ];\n\n // Wrap both requests in a single promise so that we can catch an error\n // from either request.\n return $.when.apply(null, Ajax.call(requests)).then(function(reponse1, profiles) {\n // Only return the profile.\n return profiles.length ? profiles[0] : {};\n });\n };\n\n /**\n * Decline a contact request.\n *\n * @param {int} sendingUserId The user that sent the request\n * @param {int} recipientUserId The user that received the request\n * @return {object} jQuery promise\n */\n var declineContactRequest = function(sendingUserId, recipientUserId) {\n var requests = [\n {\n methodname: 'core_message_decline_contact_request',\n args: {\n userid: sendingUserId,\n requesteduserid: recipientUserId\n }\n },\n {\n methodname: 'core_message_get_member_info',\n args: {\n referenceuserid: recipientUserId,\n userids: [sendingUserId],\n includecontactrequests: true,\n includeprivacyinfo: true\n }\n }\n ];\n\n // Wrap both requests in a single promise so that we can catch an error\n // from either request.\n return $.when.apply(null, Ajax.call(requests)).then(function(reponse1, profiles) {\n // Only return the profile.\n return profiles.length ? profiles[0] : {};\n });\n };\n\n /**\n * Get a conversation.\n *\n * @param {int} loggedInUserId The logged in user\n * @param {int} conversationId The conversation id\n * @param {bool} includeContactRequests Incldue contact requests between members\n * @param {bool} includePrivacyInfo Include privacy info for members\n * @param {int} memberLimit Limit for members\n * @param {int} memberOffset Offset for members\n * @param {int} messageLimit Limit for messages\n * @param {int} messageOffset Offset for messages\n * @param {bool} newestMessagesFirst Order the messages by newest first\n * @return {object} jQuery promise\n */\n var getConversation = function(\n loggedInUserId,\n conversationId,\n includeContactRequests,\n includePrivacyInfo,\n memberLimit,\n memberOffset,\n messageLimit,\n messageOffset,\n newestMessagesFirst\n ) {\n var args = {\n userid: loggedInUserId,\n conversationid: conversationId\n };\n\n if (typeof includeContactRequests != 'undefined' && includeContactRequests !== null) {\n args.includecontactrequests = includeContactRequests;\n }\n\n if (typeof includePrivacyInfo != 'undefined' && includePrivacyInfo !== null) {\n args.includeprivacyinfo = includePrivacyInfo;\n }\n\n if (typeof memberLimit != 'undefined' && memberLimit !== null) {\n args.memberlimit = memberLimit;\n }\n\n if (typeof memberOffset != 'undefined' && memberOffset !== null) {\n args.memberoffset = memberOffset;\n }\n\n if (typeof messageLimit != 'undefined' && messageLimit !== null) {\n args.messagelimit = messageLimit;\n }\n\n if (typeof messageOffset != 'undefined' && messageOffset !== null) {\n args.messageoffset = messageOffset;\n }\n\n if (typeof newestMessagesFirst != 'undefined' && newestMessagesFirst !== null) {\n args.newestmessagesfirst = newestMessagesFirst;\n }\n\n var request = {\n methodname: 'core_message_get_conversation',\n args: args\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Get a conversation between users.\n *\n * @param {int} loggedInUserId The logged in user\n * @param {int} otherUserId The other user id\n * @param {bool} includeContactRequests Incldue contact requests between members\n * @param {bool} includePrivacyInfo Include privacy info for members\n * @param {int} memberLimit Limit for members\n * @param {int} memberOffset Offset for members\n * @param {int} messageLimit Limit for messages\n * @param {int} messageOffset Offset for messages\n * @param {bool} newestMessagesFirst Order the messages by newest first\n * @return {object} jQuery promise\n */\n var getConversationBetweenUsers = function(\n loggedInUserId,\n otherUserId,\n includeContactRequests,\n includePrivacyInfo,\n memberLimit,\n memberOffset,\n messageLimit,\n messageOffset,\n newestMessagesFirst\n ) {\n var args = {\n userid: loggedInUserId,\n otheruserid: otherUserId\n };\n\n if (typeof includeContactRequests != 'undefined' && includeContactRequests !== null) {\n args.includecontactrequests = includeContactRequests;\n }\n\n if (typeof includePrivacyInfo != 'undefined' && includePrivacyInfo !== null) {\n args.includeprivacyinfo = includePrivacyInfo;\n }\n\n if (typeof memberLimit != 'undefined' && memberLimit !== null) {\n args.memberlimit = memberLimit;\n }\n\n if (typeof memberOffset != 'undefined' && memberOffset !== null) {\n args.memberoffset = memberOffset;\n }\n\n if (typeof messageLimit != 'undefined' && messageLimit !== null) {\n args.messagelimit = messageLimit;\n }\n\n if (typeof messageOffset != 'undefined' && messageOffset !== null) {\n args.messageoffset = messageOffset;\n }\n\n if (typeof newestMessagesFirst != 'undefined' && newestMessagesFirst !== null) {\n args.newestmessagesfirst = newestMessagesFirst;\n }\n\n var request = {\n methodname: 'core_message_get_conversation_between_users',\n args: args\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Get a self-conversation.\n *\n * @param {int} loggedInUserId The logged in user\n * @param {int} messageLimit Limit for messages\n * @param {int} messageOffset Offset for messages\n * @param {bool} newestMessagesFirst Order the messages by newest first\n * @return {object} jQuery promise\n */\n var getSelfConversation = function(\n loggedInUserId,\n messageLimit,\n messageOffset,\n newestMessagesFirst\n ) {\n var args = {\n userid: loggedInUserId\n };\n\n if (typeof messageLimit != 'undefined' && messageLimit !== null) {\n args.messagelimit = messageLimit;\n }\n\n if (typeof messageOffset != 'undefined' && messageOffset !== null) {\n args.messageoffset = messageOffset;\n }\n\n if (typeof newestMessagesFirst != 'undefined' && newestMessagesFirst !== null) {\n args.newestmessagesfirst = newestMessagesFirst;\n }\n\n var request = {\n methodname: 'core_message_get_self_conversation',\n args: args\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Get the conversations for a user.\n *\n * @param {int} userId The logged in user\n * @param {int|null} type The type of conversation to get\n * @param {int} limit Limit for results\n * @param {int} offset Offset for results\n * @param {bool|null} favourites If favourites should be included or not\n * @return {object} jQuery promise\n */\n var getConversations = function(\n userId,\n type,\n limit,\n offset,\n favourites,\n mergeself\n ) {\n var args = {\n userid: userId,\n type: type\n };\n\n if (typeof limit != 'undefined' && limit !== null) {\n args.limitnum = limit;\n }\n\n if (typeof offset != 'undefined' && offset !== null) {\n args.limitfrom = offset;\n }\n\n if (typeof favourites != 'undefined' && favourites !== null) {\n args.favourites = favourites;\n }\n\n if (typeof mergeself != 'undefined' && mergeself !== null) {\n args.mergeself = mergeself;\n }\n\n var request = {\n methodname: 'core_message_get_conversations',\n args: args\n };\n\n return Ajax.call([request])[0]\n .then(function(result) {\n if (result.conversations.length) {\n result.conversations = result.conversations.map(function(conversation) {\n if (conversation.type == CONVERSATION_TYPES.PRIVATE || conversation.type == CONVERSATION_TYPES.SELF) {\n var otherUser = conversation.members.length ? conversation.members[0] : null;\n\n if (otherUser) {\n conversation.name = conversation.name ? conversation.name : otherUser.fullname;\n conversation.imageurl = conversation.imageurl ? conversation.imageurl : otherUser.profileimageurl;\n }\n }\n\n return conversation;\n });\n }\n\n return result;\n });\n };\n\n /**\n * Get the conversations for a user.\n *\n * @param {int} conversationId The conversation id\n * @param {int} loggedInUserId The logged in user\n * @param {int} limit Limit for results\n * @param {int} offset Offset for results\n * @param {bool} includeContactRequests If contact requests should be included in result\n * @return {object} jQuery promise\n */\n var getConversationMembers = function(conversationId, loggedInUserId, limit, offset, includeContactRequests) {\n var args = {\n userid: loggedInUserId,\n conversationid: conversationId\n };\n\n if (typeof limit != 'undefined' && limit !== null) {\n args.limitnum = limit;\n }\n\n if (typeof offset != 'undefined' && offset !== null) {\n args.limitfrom = offset;\n }\n\n if (typeof includeContactRequests != 'undefined' && includeContactRequests !== null) {\n args.includecontactrequests = includeContactRequests;\n }\n\n var request = {\n methodname: 'core_message_get_conversation_members',\n args: args\n };\n\n return Ajax.call([request])[0];\n };\n\n /**\n * Set a list of conversations to set as favourites for the given user.\n *\n * @param {int} userId The user id\n * @param {array} conversationIds List of conversation ids to set as favourite\n * @return {object} jQuery promise\n */\n var setFavouriteConversations = function(userId, conversationIds) {\n\n var request = {\n methodname: 'core_message_set_favourite_conversations',\n args: {\n userid: userId,\n conversations: conversationIds\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Set a list of conversations to unset as favourites for the given user.\n *\n * @param {int} userId The user id\n * @param {array} conversationIds List of conversation ids to unset as favourite\n * @return {object} jQuery promise\n */\n var unsetFavouriteConversations = function(userId, conversationIds) {\n\n var request = {\n methodname: 'core_message_unset_favourite_conversations',\n args: {\n userid: userId,\n conversations: conversationIds\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Set a list of conversations to set as muted for the given user.\n *\n * @param {int} userId The user id\n * @param {array} conversationIds List of conversation ids to set as favourite\n * @return {object} jQuery promise\n */\n var setMutedConversations = function(userId, conversationIds) {\n var request = {\n methodname: 'core_message_mute_conversations',\n args: {\n userid: userId,\n conversationids: conversationIds\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Set a list of conversations to unset as muted for the given user.\n *\n * @param {int} userId The user id\n * @param {array} conversationIds List of conversation ids to unset as favourite\n * @return {object} jQuery promise\n */\n var unsetMutedConversations = function(userId, conversationIds) {\n var request = {\n methodname: 'core_message_unmute_conversations',\n args: {\n userid: userId,\n conversationids: conversationIds\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Get a list of user's member info.\n *\n * @param {int} referenceUserId The user id\n * @param {array} userIds List of user ids to get\n * @param {bool} includeContactRequests Include contact requests between users in response\n * @param {bool} includePrivacyInfo Include privacy info for reference user in response\n * @return {object} jQuery promise\n */\n var getMemberInfo = function(referenceUserId, userIds, includeContactRequests, includePrivacyInfo) {\n var args = {\n referenceuserid: referenceUserId,\n userids: userIds\n };\n\n if (typeof includeContactRequests != 'undefined') {\n args.includecontactrequests = includeContactRequests;\n }\n\n if (typeof includePrivacyInfo != 'undefined') {\n args.includeprivacyinfo = includePrivacyInfo;\n }\n\n var request = {\n methodname: 'core_message_get_member_info',\n args: args\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Get a list of user's member info.\n *\n * @param {int} userId The user id to mark as read for\n * @param {int} conversationId The conversation to mark as read\n * @return {object} jQuery promise\n */\n var markAllConversationMessagesAsRead = function(userId, conversationId) {\n\n var request = {\n methodname: 'core_message_mark_all_conversation_messages_as_read',\n args: {\n userid: userId,\n conversationid: conversationId\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Get the user's message preferences.\n *\n * @param {int} userId The user id to load preferences for\n * @return {object} jQuery promise\n */\n var getUserMessagePreferences = function(userId) {\n var request = {\n methodname: 'core_message_get_user_message_preferences',\n args: {\n userid: userId\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * The the count of the user's conversations grouped by type.\n *\n * @param {Number} userId The user's id.\n * @return {Object} jQuery promise.\n */\n var getTotalConversationCounts = function(userId) {\n var request = {\n methodname: 'core_message_get_conversation_counts',\n args: {\n userid: userId\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * The the count of the user's unread conversations grouped by type.\n *\n * @param {Number} userId The user's id.\n * @return {Object} jQuery promise.\n */\n var getUnreadConversationCounts = function(userId) {\n var request = {\n methodname: 'core_message_get_unread_conversation_counts',\n args: {\n userid: userId\n }\n };\n return Ajax.call([request])[0];\n };\n\n /**\n * Get both the unread and total conversation counts in a single request.\n *\n * @param {Number} userId The user's id.\n * @return {Object} jQuery promise.\n */\n var getAllConversationCounts = function(userId) {\n var requests = [\n {\n methodname: 'core_message_get_conversation_counts',\n args: {\n userid: userId\n }\n },\n {\n methodname: 'core_message_get_unread_conversation_counts',\n args: {\n userid: userId\n }\n },\n ];\n return $.when.apply(null, Ajax.call(requests)).then(function(total, unread) {\n return {\n total: total,\n unread: unread\n };\n });\n };\n\n return {\n countUnreadConversations: countUnreadConversations,\n getContacts: getContacts,\n blockUser: blockUser,\n unblockUser: unblockUser,\n createContactRequest: createContactRequest,\n deleteContacts: deleteContacts,\n getMessages: getMessages,\n searchUsers: searchUsers,\n searchMessages: searchMessages,\n sendMessagesToUser: sendMessagesToUser,\n sendMessageToUser: sendMessageToUser,\n sendMessagesToConversation: sendMessagesToConversation,\n sendMessageToConversation: sendMessageToConversation,\n savePreferences: savePreferences,\n getPreferences: getPreferences,\n deleteMessages: deleteMessages,\n deleteMessagesForAllUsers: deleteMessagesForAllUsers,\n deleteConversation: deleteConversation,\n getContactRequests: getContactRequests,\n acceptContactRequest: acceptContactRequest,\n declineContactRequest: declineContactRequest,\n getConversation: getConversation,\n getConversationBetweenUsers: getConversationBetweenUsers,\n getSelfConversation: getSelfConversation,\n getConversations: getConversations,\n getConversationMembers: getConversationMembers,\n setFavouriteConversations: setFavouriteConversations,\n setMutedConversations: setMutedConversations,\n unsetFavouriteConversations: unsetFavouriteConversations,\n unsetMutedConversations: unsetMutedConversations,\n getMemberInfo: getMemberInfo,\n markAllConversationMessagesAsRead: markAllConversationMessagesAsRead,\n getUserMessagePreferences: getUserMessagePreferences,\n getTotalConversationCounts: getTotalConversationCounts,\n getUnreadConversationCounts: getUnreadConversationCounts,\n getAllConversationCounts: getAllConversationCounts\n };\n});\n"],"file":"message_repository.min.js"} |