Commit e5d63f12 authored by Ghost User's avatar Ghost User Committed by zauberstuhl

Implement ActivityPub

parent 346a0811
...@@ -19,8 +19,10 @@ stages: ...@@ -19,8 +19,10 @@ stages:
- deploy - deploy
before_script: before_script:
- export VERSION=$(git tag -l --sort=-v:refname |head -n1) - export VERSION=$(git tag -l --sort=-v:refname |head -n1)
- mkdir -p $GOPATH/src/git.feneas.org/ganggo - export PROJECT_PATH=$GOPATH/src/git.feneas.org/ganggo
- ln -s $(pwd) $GOPATH/src/git.feneas.org/ganggo/ganggo - mkdir -p $PROJECT_PATH
- ln -s $(pwd) $PROJECT_PATH/ganggo
- cd $PROJECT_PATH/ganggo
- make install - make install
run unit tests: run unit tests:
stage: test stage: test
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
[[projects]] [[projects]]
name = "cloud.google.com/go" name = "cloud.google.com/go"
packages = ["civil"] packages = ["civil"]
revision = "aad3f485ee528456e0768f20397b4d9dd941e755" revision = "c728a003b238b26cef9ab6753a5dc424b331c3ad"
version = "v0.25.0" version = "v0.27.0"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -15,13 +15,34 @@ ...@@ -15,13 +15,34 @@
"app/controllers", "app/controllers",
"app/helpers" "app/helpers"
] ]
revision = "f4932ab8362e8e2a4e63aa88f07d17bed21f7134" revision = "2fb8ead5ef0fe4b57dbbbdf147e848fca6486480"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "git.feneas.org/ganggo/federation" name = "git.feneas.org/ganggo/federation"
packages = [
".",
"helpers"
]
revision = "76129a9a4da34965bb2cce23e5e5808a5437c2a6"
[[projects]]
name = "git.feneas.org/ganggo/gorm"
packages = [
".",
"dialects/mssql",
"dialects/mysql",
"dialects/postgres",
"dialects/sqlite"
]
revision = "c5bf88f4a1f896b106734023e9e8d68bcf9ca5ba"
version = "v1.9.3"
[[projects]]
branch = "ecdsa"
name = "git.feneas.org/ganggo/httpsignatures"
packages = ["."] packages = ["."]
revision = "59eaaf5c998263705f44bc1706686515b5f028f5" revision = "3ee9f28e5cf7db6ee603059334e87eacb08ddee9"
[[projects]] [[projects]]
name = "github.com/PuerkitoBio/goquery" name = "github.com/PuerkitoBio/goquery"
...@@ -82,8 +103,8 @@ ...@@ -82,8 +103,8 @@
"service/s3", "service/s3",
"service/sts" "service/sts"
] ]
revision = "9e9afa0895e9daff556cc18f90dc53eb91f41ffd" revision = "71a2a92b0063297b055b6f5a014d441c142da2ce"
version = "v1.14.26" version = "v1.15.32"
[[projects]] [[projects]]
name = "github.com/certifi/gocertifi" name = "github.com/certifi/gocertifi"
...@@ -104,7 +125,7 @@ ...@@ -104,7 +125,7 @@
".", ".",
"internal/cp" "internal/cp"
] ]
revision = "242fa5aa1b45aeb9fcdfeee88822982e3f548e22" revision = "1eb28afdf9b6e56cf673badd47545f844fe81103"
[[projects]] [[projects]]
name = "github.com/fatih/structs" name = "github.com/fatih/structs"
...@@ -112,17 +133,65 @@ ...@@ -112,17 +133,65 @@
revision = "a720dfa8df582c51dee1b36feabb906bde1588bd" revision = "a720dfa8df582c51dee1b36feabb906bde1588bd"
version = "v1.0" version = "v1.0"
[[projects]]
branch = "master"
name = "github.com/getlantern/byteexec"
packages = ["."]
revision = "4cfb26ec74f460fda433dc06fddfbad7ddee3072"
[[projects]]
branch = "master"
name = "github.com/getlantern/context"
packages = ["."]
revision = "624d99b1798d7c5375ea1d3ca4c5b04d58f7c775"
[[projects]]
branch = "master"
name = "github.com/getlantern/errors"
packages = ["."]
revision = "e24b7f4ff7c70be59bbefca6b7695d68cda8b399"
[[projects]]
branch = "master"
name = "github.com/getlantern/filepersist"
packages = ["."]
revision = "c5f0cd24e7991579ba6f5f1bd20a1ad2c9f06cd4"
[[projects]]
branch = "master"
name = "github.com/getlantern/golog"
packages = ["."]
revision = "cca714f7feb5df8e455f409b549d384441ac4578"
[[projects]]
branch = "master"
name = "github.com/getlantern/hex"
packages = ["."]
revision = "083fba3033ad473db3dd31c9bb368473d37581a7"
[[projects]]
branch = "master"
name = "github.com/getlantern/hidden"
packages = ["."]
revision = "d52a649ab33af200943bb599898dbdcfdbc94cb7"
[[projects]]
branch = "master"
name = "github.com/getlantern/ops"
packages = ["."]
revision = "37353306c90844c8e0591956f56611f46299d202"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/getsentry/raven-go" name = "github.com/getsentry/raven-go"
packages = ["."] packages = ["."]
revision = "ed7bcb39ff10f39ab08e317ce16df282845852fa" revision = "084a9de9eb0361fbd5ded14b55c84e5493a5d7f6"
[[projects]] [[projects]]
name = "github.com/go-ini/ini" name = "github.com/go-ini/ini"
packages = ["."] packages = ["."]
revision = "358ee7663966325963d4e8b2e1fbd570c5195153" revision = "5cf292cae48347c2490ac1a58fe36735fb78df7e"
version = "v1.38.1" version = "v1.38.2"
[[projects]] [[projects]]
name = "github.com/go-sql-driver/mysql" name = "github.com/go-sql-driver/mysql"
...@@ -130,11 +199,17 @@ ...@@ -130,11 +199,17 @@
revision = "d523deb1b23d913de5bdada721a6071e71283618" revision = "d523deb1b23d913de5bdada721a6071e71283618"
version = "v1.4.0" version = "v1.4.0"
[[projects]]
name = "github.com/go-stack/stack"
packages = ["."]
revision = "2fee6af1a9795aafbe0253a0cfbdf668e1fb8a9a"
version = "v1.8.0"
[[projects]] [[projects]]
name = "github.com/inconshreveable/log15" name = "github.com/inconshreveable/log15"
packages = ["term"] packages = ["term"]
revision = "0decfc6c20d9ca0ad143b0e89dcaa20f810b4fb3" revision = "67afb5ed74ec82fd7ac8f49d27c509ac6f991970"
version = "v2.13" version = "v2.14"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -156,12 +231,24 @@ ...@@ -156,12 +231,24 @@
] ]
revision = "9891188db5a5bdae87416218253ac3a5ed4aed8a" revision = "9891188db5a5bdae87416218253ac3a5ed4aed8a"
[[projects]]
name = "github.com/jteeuwen/go-bindata"
packages = ["."]
revision = "bbd0c6e271208dce66d8fda4bc536453cd27fc4a"
version = "v3.0.7"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/kardianos/osext" name = "github.com/kardianos/osext"
packages = ["."] packages = ["."]
revision = "ae77be60afb1dcacde03767a8c37337fad28ac14" revision = "ae77be60afb1dcacde03767a8c37337fad28ac14"
[[projects]]
branch = "master"
name = "github.com/kballard/go-shellquote"
packages = ["."]
revision = "95032a82bc518f77982ea72343cc1ade730072f0"
[[projects]] [[projects]]
name = "github.com/klauspost/compress" name = "github.com/klauspost/compress"
packages = [ packages = [
...@@ -179,14 +266,14 @@ ...@@ -179,14 +266,14 @@
version = "v1.1" version = "v1.1"
[[projects]] [[projects]]
branch = "master"
name = "github.com/lib/pq" name = "github.com/lib/pq"
packages = [ packages = [
".", ".",
"hstore", "hstore",
"oid" "oid"
] ]
revision = "90697d60dd844d5ef6ff15135d0203f65d2f53b8" revision = "4ded0e9383f75c197b3a2aaa6d590ac52df6fd79"
version = "v1.0.0"
[[projects]] [[projects]]
name = "github.com/mattn/go-colorable" name = "github.com/mattn/go-colorable"
...@@ -197,8 +284,8 @@ ...@@ -197,8 +284,8 @@
[[projects]] [[projects]]
name = "github.com/mattn/go-isatty" name = "github.com/mattn/go-isatty"
packages = ["."] packages = ["."]
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
version = "v0.0.3" version = "v0.0.4"
[[projects]] [[projects]]
name = "github.com/mattn/go-sqlite3" name = "github.com/mattn/go-sqlite3"
...@@ -212,6 +299,18 @@ ...@@ -212,6 +299,18 @@
packages = ["."] packages = ["."]
revision = "9520e82c474b0a04dd04f8a40959027271bab992" revision = "9520e82c474b0a04dd04f8a40959027271bab992"
[[projects]]
name = "github.com/microcosm-cc/bluemonday"
packages = ["."]
revision = "82c7118e8ccf7403d4860175d97bb635e8e28239"
version = "v1.0.1"
[[projects]]
branch = "master"
name = "github.com/oxtoacart/bpool"
packages = ["."]
revision = "4e1c5567d7c2dd59fa4c7c83d34c2f3528b025d6"
[[projects]] [[projects]]
name = "github.com/pkg/errors" name = "github.com/pkg/errors"
packages = ["."] packages = ["."]
...@@ -224,8 +323,8 @@ ...@@ -224,8 +323,8 @@
"harness", "harness",
"revel" "revel"
] ]
revision = "95d6366c0d8d727ca62767848fb0801268b49ea6" revision = "97ec1422620f1a83cd13738708a109fe092364ca"
version = "v0.14.1" version = "v0.19.0"
[[projects]] [[projects]]
name = "github.com/revel/config" name = "github.com/revel/config"
...@@ -278,6 +377,8 @@ ...@@ -278,6 +377,8 @@
name = "github.com/shaoshing/train" name = "github.com/shaoshing/train"
packages = [ packages = [
".", ".",
"cmd",
"command",
"interpreter" "interpreter"
] ]
revision = "c76b6fe70b70a926afe20cf76df0e237e59f4655" revision = "c76b6fe70b70a926afe20cf76df0e237e59f4655"
...@@ -296,7 +397,7 @@ ...@@ -296,7 +397,7 @@
"blowfish", "blowfish",
"md4" "md4"
] ]
revision = "a49355c7e3f8fe157a85be2f77e6e269a0f89602" revision = "0e37d006457bf46f9e6692014ba72ef82c33022c"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -306,13 +407,13 @@ ...@@ -306,13 +407,13 @@
"html/atom", "html/atom",
"websocket" "websocket"
] ]
revision = "d0887baf81f4598189d4e12a37c6da86f0bba4d0" revision = "161cd47e91fd58ac17490ef4d742dc98bb4cf60e"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = ["unix"] packages = ["unix"]
revision = "1b2967e3c290b7c545b3db0deeda16e9be4f98a2" revision = "d0be0721c37eeb5299f245a996a483160fc36940"
[[projects]] [[projects]]
name = "google.golang.org/appengine" name = "google.golang.org/appengine"
...@@ -327,8 +428,8 @@ ...@@ -327,8 +428,8 @@
"core", "core",
"terminal" "terminal"
] ]
revision = "17861e192dc11fd2f5081df1932c94cce262fa1e" revision = "f30c5d1830c892f533140f29a1de89141dc217f5"
version = "v1.6.1" version = "v1.6.2"
[[projects]] [[projects]]
name = "gopkg.in/fsnotify/fsnotify.v1" name = "gopkg.in/fsnotify/fsnotify.v1"
...@@ -338,13 +439,7 @@ ...@@ -338,13 +439,7 @@
[[projects]] [[projects]]
name = "gopkg.in/ganggo/gorm.v2" name = "gopkg.in/ganggo/gorm.v2"
packages = [ packages = ["."]
".",
"dialects/mssql",
"dialects/mysql",
"dialects/postgres",
"dialects/sqlite"
]
revision = "4cacfdfb7921a87c774cbf21382714e07ca0b44f" revision = "4cacfdfb7921a87c774cbf21382714e07ca0b44f"
version = "v2.0" version = "v2.0"
...@@ -363,6 +458,6 @@ ...@@ -363,6 +458,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "04468b6173142c89caa5e22e90c6af57fdf861768634cf0be4a8f5d8815e1b6d" inputs-digest = "84a0b763da99a39b3502dcb0d1a79d9093c73b01ef7997e9319e561bfd56d285"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
# for detailed Gopkg.toml documentation. # for detailed Gopkg.toml documentation.
# #
required = ["github.com/revel/cmd/revel"] required = [
"github.com/revel/cmd/revel",
"github.com/shaoshing/train/cmd",
"github.com/kevinburke/go-bindata",
]
[[override]] [[override]]
version = "0.19.0" version = "0.19.0"
...@@ -15,7 +19,7 @@ required = ["github.com/revel/cmd/revel"] ...@@ -15,7 +19,7 @@ required = ["github.com/revel/cmd/revel"]
name = "github.com/revel/revel" name = "github.com/revel/revel"
[[override]] [[override]]
version = "0.14.1" version = "0.19.0"
name = "github.com/revel/cmd" name = "github.com/revel/cmd"
[[override]] [[override]]
...@@ -38,10 +42,14 @@ required = ["github.com/revel/cmd/revel"] ...@@ -38,10 +42,14 @@ required = ["github.com/revel/cmd/revel"]
branch = "master" branch = "master"
name = "github.com/revel/log15" name = "github.com/revel/log15"
[[override]]
branch = "ecdsa"
name = "git.feneas.org/ganggo/httpsignatures"
[[constraint]] [[constraint]]
name = "gopkg.in/AlecAivazis/survey.v1" name = "gopkg.in/AlecAivazis/survey.v1"
version = "1.4.1" version = "1.4.1"
[[constraint]] [[constraint]]
name = "gopkg.in/ganggo/gorm.v2" name = "git.feneas.org/ganggo/gorm"
version = "2.0.0" version = "1.9.3"
...@@ -22,15 +22,20 @@ define version_info ...@@ -22,15 +22,20 @@ define version_info
endef endef
define install-tools define install-tools
# go dependencies # go dependency tool
go get -u github.com/golang/dep/cmd/dep go get -u github.com/golang/dep/cmd/dep
# download all dependencies
cd $(srcdir) && dep ensure
# web framework # web framework
go get -u github.com/revel/cmd/revel cd $(srcdir)/vendor/github.com/revel/cmd/revel && \
go build -o $$GOPATH/bin/revel
# asset compilation # asset compilation
go get -u github.com/shaoshing/train/cmd cd $(srcdir)/vendor/github.com/shaoshing/train/cmd && \
go build -o $$GOPATH/bin/train github.com/shaoshing/train/cmd go build -o $$GOPATH/bin/train
# embedding binary data e.g. assets # embedding binary data e.g. assets
go get -u github.com/jteeuwen/go-bindata/... cd $(srcdir)/vendor/github.com/kevinburke/go-bindata/go-bindata && \
go build -o $$GOPATH/bin/go-bindata
rm -r $(srcdir)/vendor/github.com/kevinburke/go-bindata/testdata
endef endef
install: clean install-deps install: clean install-deps
...@@ -46,8 +51,6 @@ ifndef godep ...@@ -46,8 +51,6 @@ ifndef godep
endif endif
# Install CSS and Javascript dependencies # Install CSS and Javascript dependencies
cd $(srcdir) && npm install --prefix . cd $(srcdir) && npm install --prefix .
# ganggo dependencies
cd $(srcdir) && dep ensure
clean: clean:
rm -r tmp vendor node_modules \ rm -r tmp vendor node_modules \
......
...@@ -25,4 +25,8 @@ ...@@ -25,4 +25,8 @@
location.reload(); location.reload();
}); });
} }
$('#stream-editor-link').click(function() {
$('#stream-editor').toggle();
});
})(); })();
...@@ -30,7 +30,9 @@ body { ...@@ -30,7 +30,9 @@ body {
} }
.nav.nav-tabs { .nav.nav-tabs {
overflow: auto; overflow-x: auto;
overflow-y: hidden;
flex-wrap: nowrap;
} }
.card img { .card img {
...@@ -50,7 +52,7 @@ body { ...@@ -50,7 +52,7 @@ body {
} }
footer { footer {
height: 2.5rem; height: auto;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
width: 100%; width: 100%;
......
...@@ -19,11 +19,11 @@ package controllers ...@@ -19,11 +19,11 @@ package controllers
import ( import (
"net/http" "net/http"
"encoding/xml"
"github.com/revel/revel" "github.com/revel/revel"
"git.feneas.org/ganggo/ganggo/app/models" "git.feneas.org/ganggo/ganggo/app/models"
"git.feneas.org/ganggo/ganggo/app/helpers" "git.feneas.org/ganggo/ganggo/app/helpers"
federation "git.feneas.org/ganggo/federation" fhelpers "git.feneas.org/ganggo/federation/helpers"
"git.feneas.org/ganggo/federation"
"strings" "strings"
) )
...@@ -58,37 +58,32 @@ func (f Fetch) Index(shareable, guid string) revel.Result { ...@@ -58,37 +58,32 @@ func (f Fetch) Index(shareable, guid string) revel.Result {
} }
if user, ok := post.IsLocal(); ok { if user, ok := post.IsLocal(); ok {
privKey, err := federation.ParseRSAPrivateKey( privKey, err := fhelpers.ParseRSAPrivateKey(
[]byte(user.SerializedPrivateKey)) []byte(user.SerializedPrivateKey))
if err != nil { if err != nil {
f.Log.Error("Fetch parse key error", "err", err) f.Log.Error("Fetch parse key error", "err", err)
return f.NotFound("record not found") return f.NotFound("record not found")
} }
entity := federation.EntityStatusMessage{ entity, err := federation.NewMessagePost(federation.DiasporaProtocol)
Text: post.Text,
Author: post.Person.Author,
Guid: post.Guid,
ProviderName: post.ProviderName,
Public: post.Public,
}
entity.CreatedAt.New(post.CreatedAt)
entityXml, err := xml.Marshal(entity)
if err != nil { if err != nil {
f.Log.Error("Fetch marshal error", "err", err) f.Log.Error("Fetch message error", "err", err)
return f.RenderError(err) return f.NotFound("record not found")
} }
entity.SetText(post.Text)
entity.SetAuthor(post.Person.Author)
entity.SetGuid(post.Guid)
entity.SetProvider(post.ProviderName)
entity.SetPublic(post.Public)
entity.SetCreatedAt(post.CreatedAt)
payload, err = federation.MagicEnvelope( payload, err = entity.Marshal(privKey, nil)
privKey, user.Person.Author, entityXml,
)
if err != nil { if err != nil {
f.Log.Error("Fetch magic envelope error", "err", err) f.Log.Error("Fetch magic envelope error", "err", err)
return f.RenderError(err) return f.RenderError(err)
} }
} else { } else {
_, host, err := helpers.ParseAuthor(post.Person.Author) host, err := helpers.ParseHost(post.Person.Author)
if err != nil { if err != nil {
f.Log.Error("Fetch parse author error", "err", err) f.Log.Error("Fetch parse author error", "err", err)
return f.RenderError(err) return f.RenderError(err)
......
...@@ -20,7 +20,8 @@ package controllers ...@@ -20,7 +20,8 @@ package controllers
import ( import (
"net/http" "net/http"
"github.com/revel/revel" "github.com/revel/revel"
federation "git.feneas.org/ganggo/federation" helpers "git.feneas.org/ganggo/federation/helpers"
"git.feneas.org/ganggo/federation"
run "github.com/revel/modules/jobs/app/jobs" run "github.com/revel/modules/jobs/app/jobs"
"git.feneas.org/ganggo/ganggo/app/models" "git.feneas.org/ganggo/ganggo/app/models"
"git.feneas.org/ganggo/ganggo/app/jobs" "git.feneas.org/ganggo/ganggo/app/jobs"
...@@ -51,26 +52,18 @@ func (r Receiver) Public() revel.Result { ...@@ -51,26 +52,18 @@ func (r Receiver) Public() revel.Result {
// in case it succeeds reply with status 202 // in case it succeeds reply with status 202
r.Response.Status = http.StatusAccepted r.Response.Status = http.StatusAccepted
msg, entity, err := federation.ParseDecryptedRequest(content) msg, err := federation.DiasporaParse(content)
if err != nil { if err != nil {
r.Log.Error("Cannot parse decrypted request", "error", err) r.Log.Error("Cannot parse content", err.Error(), err)
// NOTE Send accept code even tho the entity is not } else {
// known otherwise the sender pod will throw an error run.Now(jobs.Receiver{Message: msg})
//r.Response.Status = http.StatusNotAcceptable
return r.Render()
} }
run.Now(jobs.Receiver{
Message: msg,
Entity: entity,
})
return r.Render() return r.Render()
} }
func (r Receiver) Private() revel.Result { func (r Receiver) Private() revel.Result {
var ( var (
guid string guid string
wrapper federation.AesWrapper
person models.Person person models.Person
user models.User user models.User
) )
...@@ -82,11 +75,10 @@ func (r Receiver) Private() revel.Result { ...@@ -82,11 +75,10 @@ func (r Receiver) Private() revel.Result {
} }
defer db.Close() defer db.Close()
r.Params.BindJSON(&wrapper)
r.Params.Bind(&guid, "guid") r.Params.Bind(&guid, "guid")
r.Response.Status = http.StatusAccepted r.Response.Status = http.StatusAccepted
r.Log.Debug("AES request", "message", wrapper) r.Log.Debug("received privately", "message", string(r.Params.JSON))
err = db.Where("guid like ?", guid).First(&person).Error err = db.Where("guid like ?", guid).First(&person).Error
if err != nil { if err != nil {
...@@ -102,7 +94,7 @@ func (r Receiver) Private() revel.Result { ...@@ -102,7 +94,7 @@ func (r Receiver) Private() revel.Result {
return r.Render() return r.Render()
} }
privKey, err := federation.ParseRSAPrivateKey( privKey, err := helpers.ParseRSAPrivateKey(
[]byte(user.SerializedPrivateKey)) []byte(user.SerializedPrivateKey))
if err != nil { if err != nil {
r.Log.Error(err.Error()) r.Log.Error(err.Error())
...@@ -110,19 +102,11 @@ func (r Receiver) Private() revel.Result { ...@@ -110,19 +102,11 @@ func (r Receiver) Private() revel.Result {
return r.Render() return r.Render()