Merge branch 'master' of github.com:matrix-org/synapse into sql_refactor

This commit is contained in:
Erik Johnston 2014-08-19 16:41:13 +01:00
commit e2b861cc67
7 changed files with 100 additions and 8 deletions

View File

@ -2,7 +2,8 @@ TODO(kegan): Tweak joinalias API keys/path? Event stream historical > live needs
a token (currently doesn't). im/sync responses include outdated event formats a token (currently doesn't). im/sync responses include outdated event formats
(room membership change messages). Room config (specifically: message history, (room membership change messages). Room config (specifically: message history,
public rooms). /register seems super simplistic compared to /login, maybe it public rooms). /register seems super simplistic compared to /login, maybe it
would be better if /register used the same technique as /login? would be better if /register used the same technique as /login? /register should
be "user" not "user_id".
How to use the client-server API How to use the client-server API

View File

@ -0,0 +1,7 @@
.loggedin {
visibility: hidden;
}
p {
font-family: monospace;
}

View File

@ -0,0 +1,20 @@
<div>
<p>This registration/login demo requires a home server to be running on http://localhost:8080</p>
</div>
<form class="registrationForm">
<input type="text" id="user" placeholder="Username"></input>
<input type="password" id="password" placeholder="Password"></input>
<input type="button" class="register" value="Register"></input>
</form>
<form class="loginForm">
<input type="text" id="userLogin" placeholder="Username"></input>
<input type="password" id="passwordLogin" placeholder="Password"></input>
<input type="button" class="login" value="Login"></input>
</form>
<div class="loggedin">
<p id="welcomeText"></p>
<input type="button" class="testToken" value="Test token"></input>
<input type="button" class="logout" value="Logout"></input>
<p id="imSyncText"></p>
</div>

View File

@ -0,0 +1,69 @@
var accountInfo = {};
var showLoggedIn = function(data) {
accountInfo = data;
$(".loggedin").css({visibility: "visible"});
$("#welcomeText").text("Welcome " + accountInfo.user_id+". Your access token is: " +
accountInfo.access_token);
};
$('.register').live('click', function() {
var user = $("#user").val();
var password = $("#password").val();
$.ajax({
url: "http://localhost:8080/matrix/client/api/v1/register",
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ user_id: user, password: password }),
dataType: "json",
success: function(data) {
showLoggedIn(data);
},
error: function(err) {
alert(JSON.stringify($.parseJSON(err.responseText)));
}
});
});
var login = function(user, password) {
$.ajax({
url: "http://localhost:8080/matrix/client/api/v1/login",
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ user: user, password: password, type: "m.login.password" }),
dataType: "json",
success: function(data) {
showLoggedIn(data);
},
error: function(err) {
alert(JSON.stringify($.parseJSON(err.responseText)));
}
});
};
$('.login').live('click', function() {
var user = $("#userLogin").val();
var password = $("#passwordLogin").val();
$.getJSON("http://localhost:8080/matrix/client/api/v1/login", function(data) {
if (data.type !== "m.login.password") {
alert("I don't know how to login with this type: " + data.type);
return;
}
login(user, password);
});
});
$('.logout').live('click', function() {
accountInfo = {};
$("#imSyncText").text("");
$(".loggedin").css({visibility: "hidden"});
});
$('.testToken').live('click', function() {
var url = "http://localhost:8080/matrix/client/api/v1/im/sync?access_token=" + accountInfo.access_token + "&from=END&to=START&limit=1";
$.getJSON(url, function(data) {
$("#imSyncText").text(JSON.stringify(data, undefined, 2));
}).fail(function(err) {
$("#imSyncText").text(JSON.stringify($.parseJSON(err.responseText)));
});
});

View File

@ -231,9 +231,6 @@ class PresenceHandler(BaseHandler):
# we don't have to do this all the time # we don't have to do this all the time
self.changed_presencelike_data(target_user, state) self.changed_presencelike_data(target_user, state)
if not now_online:
del self._user_cachemap[target_user]
def changed_presencelike_data(self, user, state): def changed_presencelike_data(self, user, state):
statuscache = self._get_or_make_usercache(user) statuscache = self._get_or_make_usercache(user)

View File

@ -68,9 +68,7 @@ angular.module('matrixService', [])
params: params, params: params,
data: data, data: data,
headers: headers headers: headers
}) });
return deferred.promise;
}; };

View File

@ -76,7 +76,7 @@
<td> <td>
</td> </td>
<td> <td>
<input id="mainInput" ng-model="imageURLToSend" ng-enter="sendImage()" placeholder="Image URL"/> <input id="mainInput" ng-model="imageURLToSend" ng-enter="sendImage(imageURLToSend)" placeholder="Image URL"/>
</td> </td>
<td width="100px"> <td width="100px">
<button ng-click="sendImage(imageURLToSend)">Send URL</button> <button ng-click="sendImage(imageURLToSend)">Send URL</button>