Skip to content
This repository has been archived by the owner on Nov 30, 2017. It is now read-only.

Commit

Permalink
Database backend added & various fixes
Browse files Browse the repository at this point in the history
* Added Sqlite database for caching
* Fixed process_tweet never resolving
* Fixed messages not being emptied from queue
* Profile names automatically update
* Moved content upload function to util.js
  • Loading branch information
Half-Shot committed Jun 30, 2016
1 parent 9c29298 commit 0acbbc5
Show file tree
Hide file tree
Showing 9 changed files with 460 additions and 135 deletions.
1 change: 0 additions & 1 deletion config.sample.yaml
Expand Up @@ -5,4 +5,3 @@ bridge:
app_auth: #Get these from twitter by creating an application through the API site.
consumer_key: BLAHBLAHBLAH
consumer_secret: BLAHBLAHBLAH

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -21,6 +21,7 @@
"matrix-js-sdk": "git+ssh://git@github.com/matrix-org/matrix-js-sdk.git#develop",
"npmlog": "^3.0.0",
"oauth": "^0.9.14",
"sqlite3": "^3.1.4",
"twitter": "^1.3.0"
}
}
10 changes: 6 additions & 4 deletions src/AccountServices.js
Expand Up @@ -63,7 +63,7 @@ AccountServices.prototype.processMessage = function (event, request, context){
}
var intent = this._bridge.getIntent();
this._oauth_getAccessToken(pin,remoteSender).then(() => {
intent.sendMessage(event.room_id,{"body":"All good. You should now be able to use your twitter account on matrix.","msgtype":"m.text"});
intent.sendMessage(event.room_id,{"body":"All good. You should now be able to use your Twitter account on Matrix.","msgtype":"m.text"});
}).catch(err => {
intent.sendMessage(event.room_id,{"body":"We couldn't verify this PIN :(. Maybe you typed it wrong or you might need to request it again.","msgtype":"m.text"});
log.error("Handler.AccountServices","OAuth Access Token Failed:%s", err);
Expand All @@ -77,7 +77,7 @@ AccountServices.prototype._oauth_getAccessToken = function (pin,remoteUser) {
if(data && data.oauth_token != "" && data.oauth_secret != ""){
this._oauth.getOAuthAccessToken(data.oauth_token, data.oauth_secret, pin, (error,access_token,access_token_secret) =>{
if(error){
reject(error);
reject(error.statusCode + ": " + error.data);
}
data.access_token = access_token;
data.access_token_secret = access_token_secret;
Expand All @@ -86,13 +86,15 @@ AccountServices.prototype._oauth_getAccessToken = function (pin,remoteUser) {
resolve();
});
}
reject("User has no associated token request data");
else {
reject("User has no associated token request data");
}
});
}

AccountServices.prototype._oauth_getUrl = function(event,remoteUser){
return new Promise((resolve,reject) => {
this._oauth.getOAuthRequestToken({"x_auth_access_type":"write"},(error, oAuthToken, oAuthTokenSecret, results) => {
this._oauth.getOAuthRequestToken({"x_auth_access_type":"dm"},(error, oAuthToken, oAuthTokenSecret, results) => {
if(error){
reject(["Couldn't get token for user.\n%s",error]);
}
Expand Down
2 changes: 0 additions & 2 deletions src/HashtagHandler.js
Expand Up @@ -8,8 +8,6 @@ var HashtagHandler = function (bridge, twitter) {


HashtagHandler.prototype.processInvite = function (event, request, context) {
var intent = this._bridge.getIntent(event.state_key);
intent.leave(event.room_id);
return;//No invites
}

Expand Down

0 comments on commit 0acbbc5

Please sign in to comment.