Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' of github.com:matrix-org/synapse into federati…
Browse files Browse the repository at this point in the history
…on_authorization
  • Loading branch information
erikjohnston committed Nov 7, 2014
2 parents 49948d7 + 4b256ca commit 3cb678f
Show file tree
Hide file tree
Showing 87 changed files with 2,155 additions and 744 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ graph/*.svg
graph/*.png
graph/*.dot

webclient/config.js
**/webclient/config.js
webclient/test/environment-protractor.js

uploads
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
recursive-include docs *
recursive-include tests *.py
recursive-include synapse/persistence/schema *.sql
recursive-include synapse/storage/schema *.sql
recursive-include syweb/webclient *
53 changes: 29 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ Thanks for trying Matrix!

[2] End-to-end encryption is currently in development


Homeserver Installation
=======================

First, the dependencies need to be installed. Start by installing
'python2.7-dev' and the various tools of the compiler toolchain.
Synapse is written in python but some of the libraries is uses are written in
C. So before we can install synapse itself we need a working C compiler and the
header files for python C extensions.

Installing prerequisites on Ubuntu::

Expand All @@ -137,29 +137,34 @@ Installing prerequisites on Mac OS X::

$ xcode-select --install

The homeserver has a number of external dependencies, that are easiest
to install by making setup.py do so, in --user mode::
Synapse uses NaCl (http://nacl.cr.yp.to/) for encryption and digital
signatures. Unfortunately PyNACL currently has a few issues
(https://github.com/pyca/pynacl/issues/53) and
(https://github.com/pyca/pynacl/issues/79) that mean it may not install
correctly. To fix try re-installing from PyPI or directly from (https://github.com/pyca/pynacl)::

$ python setup.py develop --user
$ # Install from PyPI
$ pip install --user --upgrade --force pynacl
$ # Install from github
$ pip install --user https://github.com/pyca/pynacl/tarball/master

You'll need a version of setuptools new enough to know about git, so you
may need to also run::
On OSX, if you encounter ``clang: error: unknown argument: '-mno-fused-madd'``
you will need to ``export CFLAGS=-Qunused-arguments``.

$ sudo apt-get install python-pip
$ sudo pip install --upgrade setuptools
To install the synapse homeserver run::

If you don't have access to github, then you may need to install ``syutil``
manually by checking it out and running ``python setup.py develop --user`` on
it too.
$ pip install --user --process-dependency-links https://github.com/matrix-org/synapse/tarball/master

If you get errors about ``sodium.h`` being missing, you may also need to
manually install a newer PyNaCl via pip as setuptools installs an old one. Or
you can check PyNaCl out of git directly (https://github.com/pyca/pynacl) and
installing it. Installing PyNaCl using pip may also work (remember to remove
any other versions installed by setuputils in, for example, ~/.local/lib).
This installs synapse, along with the libraries it uses, into
``$HOME/.local/lib/``.

On OSX, if you encounter ``clang: error: unknown argument: '-mno-fused-madd'``
you will need to ``export CFLAGS=-Qunused-arguments``.
Homeserver Development
======================

The homeserver has a number of external dependencies, that are easiest
to install by making setup.py do so, in --user mode::

$ python setup.py develop --user

This will run a process of downloading and installing into your
user's .local/lib directory all of the required dependencies that are
Expand Down Expand Up @@ -204,11 +209,11 @@ IDs:
For the first form, simply pass the required hostname (of the machine) as the
--host parameter::

$ python synapse/app/homeserver.py \
$ python -m synapse.app.homeserver \
--server-name machine.my.domain.name \
--config-path homeserver.config \
--generate-config
$ python synapse/app/homeserver.py --config-path homeserver.config
$ python -m synapse.app.homeserver --config-path homeserver.config

Alternatively, you can run synapse via synctl - running ``synctl start`` to
generate a homeserver.yaml config file, where you can then edit server-name to
Expand All @@ -226,12 +231,12 @@ record would then look something like::
At this point, you should then run the homeserver with the hostname of this
SRV record, as that is the name other machines will expect it to have::

$ python synapse/app/homeserver.py \
$ python -m synapse.app.homeserver \
--server-name YOURDOMAIN \
--bind-port 8448 \
--config-path homeserver.config \
--generate-config
$ python synapse/app/homeserver.py --config-path homeserver.config
$ python -m synapse.app.homeserver --config-path homeserver.config


You may additionally want to pass one or more "-v" options, in order to
Expand Down
2 changes: 1 addition & 1 deletion demo/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ for port in 8080 8081 8082; do
done

echo "Starting webclient on port 8000..."
python "demo/webserver.py" -p 8000 -P "$DIR/webserver.pid" "webclient"
python "demo/webserver.py" -p 8000 -P "$DIR/webserver.pid" "syweb/webclient"

cd "$CWD"
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def read(fname):
setup(
name="SynapseHomeServer",
version="0.0.1",
packages=find_packages(exclude=["tests"]),
packages=find_packages(exclude=["tests", "tests.*"]),
description="Reference Synapse Home Server",
install_requires=[
"syutil==0.0.2",
Expand All @@ -43,6 +43,7 @@ def read(fname):
],
dependency_links=[
"https://github.com/matrix-org/syutil/tarball/v0.0.2#egg=syutil-0.0.2",
"https://github.com/pyca/pynacl/tarball/52dbe2dc33f1#egg=pynacl-0.3.0",
],
setup_requires=[
"setuptools_trial",
Expand Down
5 changes: 4 additions & 1 deletion synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import re
import sys
import sqlite3
import syweb

logger = logging.getLogger(__name__)

Expand All @@ -58,7 +59,9 @@ def build_resource_for_federation(self):
return JsonResource()

def build_resource_for_web_client(self):
return File("webclient") # TODO configurable?
syweb_path = os.path.dirname(syweb.__file__)
webclient_path = os.path.join(syweb_path, "webclient")
return File(webclient_path) # TODO configurable?

def build_resource_for_content_repo(self):
return ContentRepoResource(
Expand Down
6 changes: 3 additions & 3 deletions synapse/rest/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def on_PUT(self, request, room_id, event_type, state_key):
content = _parse_json(request)

event = self.event_factory.create_event(
etype=event_type,
etype=urllib.unquote(event_type),
content=content,
room_id=urllib.unquote(room_id),
user_id=user.to_string(),
Expand Down Expand Up @@ -182,7 +182,7 @@ def on_POST(self, request, room_id, event_type):
content = _parse_json(request)

event = self.event_factory.create_event(
etype=event_type,
etype=urllib.unquote(event_type),
room_id=urllib.unquote(room_id),
user_id=user.to_string(),
content=content
Expand Down Expand Up @@ -458,7 +458,7 @@ def on_POST(self, request, room_id, event_id):
room_id=urllib.unquote(room_id),
user_id=user.to_string(),
content=content,
redacts=event_id,
redacts=urllib.unquote(event_id),
)

msg_handler = self.handlers.message_handler
Expand Down
Empty file added syweb/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ limitations under the License.
'use strict';

angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'eventStreamService'])
.controller('MatrixWebClientController', ['$scope', '$location', '$rootScope', '$timeout', '$animate', 'matrixService', 'mPresence', 'eventStreamService', 'eventHandlerService', 'matrixPhoneService',
function($scope, $location, $rootScope, $timeout, $animate, matrixService, mPresence, eventStreamService, eventHandlerService, matrixPhoneService) {
.controller('MatrixWebClientController', ['$scope', '$location', '$rootScope', '$timeout', '$animate', 'matrixService', 'mPresence', 'eventStreamService', 'eventHandlerService', 'matrixPhoneService', 'modelService',
function($scope, $location, $rootScope, $timeout, $animate, matrixService, mPresence, eventStreamService, eventHandlerService, matrixPhoneService, modelService) {

// Check current URL to avoid to display the logout button on the login page
$scope.location = $location.path();
Expand Down Expand Up @@ -117,7 +117,7 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
return;
}

var roomMembers = angular.copy($rootScope.events.rooms[$rootScope.currentCall.room_id].members);
var roomMembers = angular.copy(modelService.getRoom($rootScope.currentCall.room_id).current_room_state.members);
delete roomMembers[matrixService.config().user_id];

$rootScope.currentCall.user_id = Object.keys(roomMembers)[0];
Expand Down
File renamed without changes.
15 changes: 2 additions & 13 deletions webclient/app-filter.js → syweb/webclient/app-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ angular.module('matrixWebClient')
return s + "s";
}
if (t < 60 * 60) {
return m + "m "; // + s + "s";
return m + "m"; // + s + "s";
}
if (t < 24 * 60 * 60) {
return h + "h "; // + m + "m";
return h + "h"; // + m + "m";
}
return d + "d "; // + h + "h";
};
Expand Down Expand Up @@ -76,17 +76,6 @@ angular.module('matrixWebClient')
return filtered;
};
})
.filter('stateEventsFilter', function($sce) {
return function(events) {
var filtered = {};
angular.forEach(events, function(value, key) {
if (value && typeof(value.state_key) === "string") {
filtered[key] = value;
}
});
return filtered;
};
})
.filter('unsafe', ['$sce', function($sce) {
return function(text) {
return $sce.trustAsHtml(text);
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions webclient/app.js → syweb/webclient/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var matrixWebClient = angular.module('matrixWebClient', [
'eventStreamService',
'eventHandlerService',
'notificationService',
'modelService',
'infinite-scroll',
'ui.bootstrap',
'monospaced.elastic'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ angular.module('mFileUpload', ['matrixService', 'mUtilities'])
var imageMessage = {
msgtype: "m.image",
url: undefined,
body: {
body: "Image",
info: {
size: undefined,
w: undefined,
h: undefined,
Expand All @@ -90,7 +91,7 @@ angular.module('mFileUpload', ['matrixService', 'mUtilities'])
function(url) {
// Update message metadata
imageMessage.url = url;
imageMessage.body = {
imageMessage.info = {
size: imageFile.size,
w: size.width,
h: size.height,
Expand All @@ -101,7 +102,7 @@ angular.module('mFileUpload', ['matrixService', 'mUtilities'])
// reuse the original image info for thumbnail data
if (!imageMessage.thumbnail_url) {
imageMessage.thumbnail_url = imageMessage.url;
imageMessage.thumbnail_info = imageMessage.body;
imageMessage.thumbnail_info = imageMessage.info;
}

// We are done
Expand Down
Loading

0 comments on commit 3cb678f

Please sign in to comment.