-
-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Message Archive Management (XEP-0313) #432
Changes from 2 commits
0a20cd1
cbc0be0
8987501
ce672ad
b5d5e6c
0c243cc
e76a1bf
1f9701c
ecde12c
8fd3e88
c5422d6
f0c3aae
ba99b66
4dc3eb0
d6f78c7
494302d
9525f6f
e6a33f2
93580ea
48a928f
7676a79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ jsxc.storage = { | |
/** | ||
* Prefix for localstorage | ||
* | ||
* @privat | ||
* @private | ||
*/ | ||
PREFIX: 'jsxc', | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,14 +27,111 @@ | |
* | ||
*/ | ||
|
||
/*jsxc.xmpp.mam = { | ||
jsxc.xmpp.mam = { | ||
conn: jsxc.xmpp.conn | ||
}; | ||
|
||
jsxc.xmpp.mam.init = function(){ | ||
var self = jsxc.xmpp.mam; | ||
self.getHistory(userid, count, before); | ||
};*/ | ||
var self = jsxc.xmpp.conn.mam; | ||
console.log(self); | ||
|
||
//self has now the object of the strophe.mam | ||
// make a call to the get history function. | ||
|
||
|
||
//self.getHistory(userid, count, before); | ||
}; | ||
|
||
|
||
jsxc.xmpp.mam.getHistory = function(bid) { | ||
/* | ||
To include the whole functionality of strophe-plugin we used self | ||
*/ | ||
var self = jsxc.xmpp.conn.mam; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I use 'this' than? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ??? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to make sure, that the connection has already be established. See e.g. jsxc.lib.xmpp.chatState.js#L17 |
||
/* | ||
ownjid is the jid of the person who is logged in | ||
*/ | ||
var ownjid = jsxc.xmpp.conn.jid; | ||
|
||
// Now we are converting the jid into bid | ||
var ownbid = jsxc.jidToBid(ownjid); | ||
|
||
|
||
// We are calling the strophe plugin as specified by them | ||
self.query(ownbid, { | ||
with: bid, | ||
before: "", | ||
onMessage: function(message) { | ||
/* | ||
The message looks like this: | ||
<message xmlns="jabber:client" from="ownbid" to="bid"> | ||
<result xmlns="urn:xmpp:mam:0" id="1485155123866746"> | ||
<forwarded xmlns="urn:xmpp:forward:0"> | ||
<message xmlns="jabber:client" from="jid from which message is sent" to="bid who recived the message" type="chat" id="1485141093744:msg"> | ||
<body>gdhjcb</body> | ||
<request xmlns="urn:xmpp:receipts"></request> | ||
<delay xmlns="urn:xmpp:delay" from="serverAddress" stamp="2017-01-23T03:11:43.446Z">Offline Storage</delay> | ||
</message> | ||
<delay xmlns="urn:xmpp:delay" from="serverAddress" stamp="2017-01-23T07:05:23.867Z"></delay> | ||
</forwarded> | ||
</result> | ||
<no-store xmlns="urn:xmpp:hints"></no-store> | ||
</message> | ||
|
||
*/ | ||
var direction; | ||
|
||
/* | ||
Check the direction of the message i.e. In which direction messages are exchanged. | ||
*/ | ||
if(bid === $(message).find("forwarded message").attr("to")){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use also the xml namespace to identify the forwarded element. See jsxc.lib.xmpp.js#L789. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is always equal to "forwarded xmlns="urn:xmpp:forward:0"". What do we need to check here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future there could be an element with the same name, but different behavior. |
||
direction = "out"; | ||
} | ||
else{ | ||
direction = "in"; | ||
} | ||
var timeOfMessage = $(message).find("forwarded delay").attr("stamp"); | ||
var stamp = new Date(timeOfMessage).getTime(); | ||
var msgBody = $(message).find("forwarded message body").text(); | ||
var mamUid = stamp + ":msg"; | ||
var msg = { | ||
"_uid": mamUid, | ||
"_received": false, | ||
"encrypted": false, | ||
|
||
/* | ||
forwarded is true becuase we don't want the user to get notifications | ||
of the old messages | ||
*/ | ||
"forwarded": true, | ||
/* | ||
For stamp we pass the number of milliseconds that have been passed since | ||
05 January, 1975 | ||
*/ | ||
"stamp": stamp, | ||
|
||
"type": "plain", | ||
"bid": bid, | ||
"direction": direction, | ||
"msg": msgBody | ||
}; | ||
|
||
//console.log(message); | ||
//console.log(mamUid); | ||
|
||
jsxc.storage.setUserItem('msg', mamUid, msg); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. This will be removed. |
||
//This line is not working | ||
jsxc.gui.window.postMessage(msg); | ||
|
||
//console.log("Message from ", $(message).find("forwarded message").attr("from"), " on ", $(message).find("forwarded delay").attr("stamp"),": ", $(message).find("forwarded message body").text() ); | ||
return true; | ||
}, | ||
onComplete: function(response) { | ||
console.log("Got all the messages"); | ||
console.log(response); | ||
} | ||
}); | ||
}; | ||
|
||
//example code to query an personal archive for conversations with | ||
//juliet@capulet.com | ||
|
@@ -93,5 +190,4 @@ connection.mam.query("you@example.com", { | |
jsxc.xmpp.conn.mam.query(jsxc.bid, q); | ||
} | ||
}; | ||
*/ | ||
|
||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an event handler for this. I think the appropriate event would be
init.window.jsxc
.