· 8 years ago · Dec 01, 2017, 07:24 AM
1Action_sent_mdc = function(msg, idChat) {
2 var currentTime = $.now();
3
4 if(msg != undefined && msg != ''){
5 var chat_pageID = $('.chat_row[idChat="' + idChat + '"]').attr('PageID');
6 var conversation_id_mdc = $('.chat_row[idChat="' + idChat + '"]').attr('conversation_id_mdc');
7 var fomat_sent = {
8
9 conversation_id : conversation_id_mdc,
10 secret_key : "c924a224d3a0d199702b48463cc5fea8",
11 app_id : "bcd77910565d7733aabb15a16d94c2cfa8f9a7d7",
12 message: {
13 conversation_id : conversation_id_mdc,
14 secret_key : "c924a224d3a0d199702b48463cc5fea8",
15 app_id : "bcd77910565d7733aabb15a16d94c2cfa8f9a7d7",
16 project_id: thisProjectToken,
17 time: currentTime,
18 is_support: 1,
19 messaging: {
20 sender:{
21 id: thisSupport_Id
22 },
23 recipient: {
24 id: idChat
25 },
26 message:{
27 mid : "mid.chat." + currentTime,
28 text : msg
29 }
30 }
31 }
32
33 };
34 console.log(JSON.stringify(fomat_sent))
35
36 var link = 'https://appmdc.sohatv.vn/realtime/send/message';
37 try {
38 idChat = idChat.replace('fb_comment_','');
39 idChat = idChat.replace('fp_' + chat_pageID +'_','');
40
41 $.ajax({
42 type: "POST",
43 url: link,
44 contentType: "application/json; charset=utf-8",
45 data: JSON.stringify(fomat_sent),
46 dataType: "json",
47 success: function (msg) {
48 if (msg) {
49 console.log('sent ok');
50
51 } else {
52 console.log('sent false');
53 }
54 },
55
56
57 });
58 } catch (err){
59 debugjs(err);
60 }
61 }
62}