Giter VIP home page Giter VIP logo

brutalinks's People

Contributors

mariusor avatar muesli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brutalinks's Issues

Repo name

I noticed something a bit unusual in the Go world, which is the repo name having a .go suffix. This is known to cause various problems with tooling, go get and even go build. I know you're using a Makefile to work around that, but unless you plan a second app called littr I'd like to suggest renaming the repository to simply littr.

Fix Outbox Collections

Outbox collections contain Actions not Object items. Need to fix to be able to interact with other AP instances.

Error bootstrapping a database

I am trying to set up an instance of littr.go, but unfortunately I'm quite bad at debugging SQL-related issues. When I attempt to bootstrap the database, I get the following error:

    time="2019-08-27T23:00:51-04:00" level=error msg="query: create table items (
    id serial constraint items_pk primary key,
    key char(32) unique,
    mime_type varchar default NULL,
    title varchar default NULL,
    data text default NULL,
    score bigint default 0,
    path ltree default NULL,
    submitted_by int references accounts(id),
    submitted_at timestamp default current_timestamp,
    updated_at timestamp default current_timestamp,
    metadata jsonb default '{}',
    flags bit(8) default 0::bit(8)
    );" file=/home/dev/go/src/github.com/mariusor/littr.go/app/cmd/bootstrap.go line=373 trace="goroutine 1 [running]:
    runtime/debug.Stack(0x9eca36, 0x9, 0xc00025bc28)
        /snap/go/4301/src/runtime/debug/stack.go:24 +0x9d
    github.com/mariusor/littr.go/internal/errors.Annotatef(0xaab100, 0xc0000c1c20, 0x9eca36, 0x9, 0xc00025bc28, 0x1, 0x1, 0x0, 0x0)
        /home/dev/go/src/github.com/mariusor/littr.go/internal/errors/errors.go:91 +0xad
    github.com/mariusor/littr.go/app/cmd.BootstrapDB(0xc0000a61c0, 0x0, 0x0)
        /home/dev/go/src/github.com/mariusor/littr.go/app/cmd/bootstrap.go:373 +0xa6e
    main.main()
        /home/dev/go/src/github.com/mariusor/littr.go/cli/bootstrap/main.go:77 +0x54b
    "

Is this a bug, or am I missing something?

Validate HTML

Can we improve the results of running littr.me through an HTML validator? https://validator.w3.org/nu/?doc=https%3A%2F%2Flittr.me

The only error (as opposed to mere warnings) seems to be 24 copies of "Element a is missing required attribute href." Can we get an href into the code there? Is it necessary to have links that don't go anywhere?

I recognize that validators can be annoying and inflexible at times (and sometimes out of date / unaware of the latest standards), but validation can help catch mistakes in our code, and standards compliance is how we keep the web open to everyone, not just the currently dominant players, so I think it's worth the effort. I also understand this is alpha software, but I think that getting into the habit of validating HTML is a good idea.

Fix strings coming from json

Currently the JSON unmarshalling leaves \uXXXX and \n\r\t sequences of characters as is, instead of replacing them with corresponding runes. I'm not sure it's a activitypub.go/jsonld problem or not.

Item - Load Item and all its children

See #2

Since our basic Item is an ActivityPub Article object, and it doesn't have an outbox itself, this will be tricky to implement using strictly the AP spec.

An idea would be to have a way of filtering items by Audience - and expose it for Article items.

[Updated] All AP Objects have a Replies collection. I populate this collection with the URIs of those items.

Hard crash due to logging

Due to the changes of passing the request logging through our cludge log package, we missed protecting the context map with mutexes in a couple of places, which triggers some hard crashes when request concurrency is high.

Many thanx to @[email protected] for noticing this.

fatal error: concurrent map iteration and map write

goroutine 2981 [running]:
runtime.throw(0xb11062, 0x26)
	/usr/lib/go/src/runtime/panic.go:608 +0x72 fp=0xc0004a40a8 sp=0xc0004a4078 pc=0x42c082
runtime.mapiternext(0xc0004a4178)
	/usr/lib/go/src/runtime/map.go:790 +0x525 fp=0xc0004a4130 sp=0xc0004a40a8 pc=0x40ecf5
github.com/mariusor/littr.go/internal/log.(*logger).context(0xc000ea89c0, 0x0)
	/littr.go/internal/log/logger.go:85 +0x11b fp=0xc0004a41e8 sp=0xc0004a4130 pc=0x7fb5fb
github.com/mariusor/littr.go/internal/log.logger.Debugf(0xbcc6a0, 0xc00005e180, 0xc0002f5890, 0x100000002, 0x0, 0x0, 0xaf2eb3, 0x2, 0xc000c25600, 0x1, ...)
	/littr.go/internal/log/logger.go:120 +0x71 fp=0xc0004a4260 sp=0xc0004a41e8 pc=0x7fbc91
github.com/mariusor/littr.go/internal/log.(*logger).Debugf(0xc0002f5860, 0xaf2eb3, 0x2, 0xc000c25600, 0x1, 0x1)
	<autogenerated>:1 +0x8d fp=0xc0004a42c8 sp=0xc0004a4260 pc=0x7fd87d
github.com/mariusor/littr.go/app/api.New.func2(0xc000671760, 0x2, 0x2)
	/littr.go/app/api/loader.go:42 +0x1b6 fp=0xc0004a4340 sp=0xc0004a42c8 pc=0x9a1006
github.com/go-ap/activitypub/client.client.Get(0xb264e8, 0xc0008d9740, 0x5b, 0xa0d1c0, 0xac4e01, 0xc0006e9560)
	GOPATH/share/go/pkg/mod/github.com/go-ap/[email protected]/client/client.go:157 +0x137 fp=0xc0004a43c8 sp=0xc0004a4340 pc=0x97cb97
github.com/go-ap/activitypub/client.(*client).Get(0xc00000c908, 0xc0008d9740, 0x5b, 0x3, 0xc0006e95e8, 0xc0008d9740)
	<autogenerated>:1 +0x50 fp=0xc0004a4408 sp=0xc0004a43c8 pc=0x97d470
github.com/mariusor/littr.go/app/api.(*repository).LoadItems(0xc0002a9a00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/littr.go/app/api/loader.go:597 +0x3ba fp=0xc0004a46f0 sp=0xc0004a4408 pc=0x996a7a
github.com/mariusor/littr.go/app/frontend.loadItems(0xbc4ac0, 0xc000ea8810, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/littr.go/app/frontend/listing.go:203 +0xfa fp=0xc0004a4c88 sp=0xc0004a46f0 pc=0x96f14a
github.com/mariusor/littr.go/app/frontend.(*handler).HandleIndex(0xc00043cf00, 0x7fc639c9f200, 0xc000ec4180, 0xc000677000)
	/littr.go/app/frontend/listing.go:179 +0x36d fp=0xc0004a5498 sp=0xc0004a4c88 pc=0x96e92d
github.com/mariusor/littr.go/app/frontend.(*handler).HandleIndex-fm(0x7fc639c9f200, 0xc000ec4180, 0xc000677000)
	/littr.go/app/frontend/routes.go:23 +0x48 fp=0xc0004a54c8 sp=0xc0004a5498 pc=0x979e08
net/http.HandlerFunc.ServeHTTP(0xc00029d710, 0x7fc639c9f200, 0xc000ec4180, 0xc000677000)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a54f0 sp=0xc0004a54c8 pc=0x766634
github.com/go-chi/chi.(*Mux).routeHTTP(0xc000410d20, 0x7fc639c9f200, 0xc000ec4180, 0xc000677000)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:424 +0x239 fp=0xc0004a5560 sp=0xc0004a54f0 pc=0x798fa9
github.com/go-chi/chi.(*Mux).routeHTTP-fm(0x7fc639c9f200, 0xc000ec4180, 0xc000677000)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:368 +0x48 fp=0xc0004a5590 sp=0xc0004a5560 pc=0x79d6a8
net/http.HandlerFunc.ServeHTTP(0xc00029d700, 0x7fc639c9f200, 0xc000ec4180, 0xc000677000)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a55b8 sp=0xc0004a5590 pc=0x766634
github.com/go-chi/chi/middleware.RequestLogger.func1.1(0xbc4240, 0xc00091c380, 0xc000676f00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/middleware/logger.go:46 +0x1b6 fp=0xc0004a5650 sp=0xc0004a55b8 pc=0x7ed8d6
net/http.HandlerFunc.ServeHTTP(0xc0002f5a70, 0xbc4240, 0xc00091c380, 0xc000676f00)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a5678 sp=0xc0004a5650 pc=0x766634
github.com/mariusor/littr.go/app.NeedsDBBackend.func1.1(0xbc4240, 0xc00091c380, 0xc000676f00)
	/littr.go/app/app.go:383 +0x135 fp=0xc0004a56d8 sp=0xc0004a5678 pc=0x8920c5
net/http.HandlerFunc.ServeHTTP(0xc00032b8a0, 0xbc4240, 0xc00091c380, 0xc000676f00)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a5700 sp=0xc0004a56d8 pc=0x766634
github.com/mariusor/littr.go/app/frontend.(*handler).LoadSession.func1(0xbc4240, 0xc00091c380, 0xc000676f00)
	/littr.go/app/frontend/frontend.go:750 +0x141 fp=0xc0004a5868 sp=0xc0004a5700 pc=0x975ac1
net/http.HandlerFunc.ServeHTTP(0xc00032b8c0, 0xbc4240, 0xc00091c380, 0xc000676f00)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a5890 sp=0xc0004a5868 pc=0x766634
github.com/go-chi/chi/middleware.GetHead.func1(0xbc4240, 0xc00091c380, 0xc000676f00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/middleware/get_head.go:37 +0x14a fp=0xc0004a5900 sp=0xc0004a5890 pc=0x7ed57a
net/http.HandlerFunc.ServeHTTP(0xc00032b8e0, 0xbc4240, 0xc00091c380, 0xc000676f00)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a5928 sp=0xc0004a5900 pc=0x766634
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc000410d20, 0xbc4240, 0xc00091c380, 0xc000676f00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:69 +0x44f fp=0xc0004a59a0 sp=0xc0004a5928 pc=0x79709f
github.com/go-chi/chi.(*Mux).Mount.func1(0xbc4240, 0xc00091c380, 0xc000676f00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:291 +0xf5 fp=0xc0004a5a00 sp=0xc0004a59a0 pc=0x79cba5
net/http.HandlerFunc.ServeHTTP(0xc0004de820, 0xbc4240, 0xc00091c380, 0xc000676f00)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a5a28 sp=0xc0004a5a00 pc=0x766634
github.com/mariusor/littr.go/app/api.handler.Repository.func1(0xbc4240, 0xc00091c380, 0xc000676e00)
	/littr.go/app/api/loader.go:132 +0x18f fp=0xc0004a5ac0 sp=0xc0004a5a28 pc=0x9a11ef
net/http.HandlerFunc.ServeHTTP(0xc0000a1900, 0xbc4240, 0xc00091c380, 0xc000676e00)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a5ae8 sp=0xc0004a5ac0 pc=0x766634
github.com/go-chi/chi.(*ChainHandler).ServeHTTP(0xc0000a1940, 0xbc4240, 0xc00091c380, 0xc000676e00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/chain.go:31 +0x52 fp=0xc0004a5b18 sp=0xc0004a5ae8 pc=0x7963a2
github.com/go-chi/chi.(*Mux).routeHTTP(0xc000410c60, 0xbc4240, 0xc00091c380, 0xc000676e00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:424 +0x239 fp=0xc0004a5b88 sp=0xc0004a5b18 pc=0x798fa9
github.com/go-chi/chi.(*Mux).routeHTTP-fm(0xbc4240, 0xc00091c380, 0xc000676e00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:368 +0x48 fp=0xc0004a5bb8 sp=0xc0004a5b88 pc=0x79d6a8
net/http.HandlerFunc.ServeHTTP(0xc00029d690, 0xbc4240, 0xc00091c380, 0xc000676e00)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a5be0 sp=0xc0004a5bb8 pc=0x766634
github.com/go-chi/chi/middleware.RequestID.func1(0xbc4240, 0xc00091c380, 0xc000676d00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/middleware/request_id.go:68 +0x285 fp=0xc0004a5ca8 sp=0xc0004a5be0 pc=0x7edf15
net/http.HandlerFunc.ServeHTTP(0xc00032b820, 0xbc4240, 0xc00091c380, 0xc000676d00)
	/usr/lib/go/src/net/http/server.go:1964 +0x44 fp=0xc0004a5cd0 sp=0xc0004a5ca8 pc=0x766634
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc000410c60, 0xbc4240, 0xc00091c380, 0xc000676c00)
	GOPATH/share/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:81 +0x293 fp=0xc0004a5d48 sp=0xc0004a5cd0 pc=0x796ee3
net/http.serverHandler.ServeHTTP(0xc000073450, 0xbc4240, 0xc00091c380, 0xc000676c00)
	/usr/lib/go/src/net/http/server.go:2741 +0xab fp=0xc0004a5d78 sp=0xc0004a5d48 pc=0x76928b
net/http.(*conn).serve(0xc0001fe1e0, 0xbc4a00, 0xc000ec4080)
	/usr/lib/go/src/net/http/server.go:1847 +0x646 fp=0xc0004a5fc8 sp=0xc0004a5d78 pc=0x765696
runtime.goexit()
	/usr/lib/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0004a5fd0 sp=0xc0004a5fc8 pc=0x45bac1
created by net/http.(*Server).Serve
	/usr/lib/go/src/net/http/server.go:2851 +0x2f5

Dog fooding

Basically this means to move all the frontend functionality to use ActivityPub API calls to our own api/ end-points.

  • Index - Load Top Level Items #3

  • Domain/User - Load All Items with conditions #4

  • Item - Load Item and all its children #5

  • Likes - Load likes/dislikes #11

  • Item Actions: New Item - Create Activity Pub Item as Current Account #13

  • Item Actions: Like/Dislike - Create a new Like/Dislike activity for Item #12

  • Item Actions: Edit/Delete - Allow Current Account to perform actions on Item #17

  • Load Current Account - Load all interesting information about current account #16

  • Login - no idea yet how this can be done using ActivityPub

  • Register - no idea yet how this can be done using ActivityPub

Item Actions: New Item

See #2

Add create items capability to the API.

It should use the Create activity of ActivityPub.

Add i18n for others languages support

Littr looks promising but it's actually only available in english. It would be nice for instances owners to deploy littr in their own languages to build their own communities.

What do you think ?

Use sqlx for query generation

We currently use hand baked queries for the models package, which look a bit nasty and complicated.

I'm sure we can replace at least some of them with sqlx generated ones.

Move to a more consistent "Repository" design pattern

Currently we use a repository pattern for abstracting the access to the DB and API.

I need to move the functionality related to this to its own package and extricate it from the existing ones, which are using their own custom entities (API uses AP structs and DB uses local ORM specific structs).

We need to abstract "hydrator/mapper" helper functions from the underlying structs of each package.

After all of this is done we can move to add a Redis or ElasticSearch repository (or maybe one of the options mentioned in #9).

Domain/User - Load All Items with conditions

See #2

Use the api/outbox end-point but add filtering capabilities.

Needed filters:

  • type - for the case where we want to go back to distinguish between submitted links or self posts
  • mediaType
  • submittedBy
  • content/contentMatchType
  • inReplyTo - incomplete (used to get first level children of item)
  • context - used to get all children and grandchildren if item

❓ Should I drop the domain page ?
❗ Nope. Solved the domain page by using content with contentMatchType=fuzzy

http://localhost:3000/api/outbox?content=http%255Bs%255D%253F%253A%252F%252Flobste.rs&contentMatchType=8&mediaType=application%252Furl

getting started: a few hiccups

I didn't want to modify my pg_hba.conf rules to allow access to the postgres user, so I read the bootstrap code and ran the SQL files manually. I had to make this change to db/init.sql:

diff --git a/db/init.sql b/db/init.sql
index 8a46b30..784338d 100644
--- a/db/init.sql
+++ b/db/init.sql
@@ -1,7 +1,10 @@
 -- name: drop-tables
+drop table if exists objects;
+drop table if exists votes;
 drop table if exists items;
 drop table if exists accounts;
-drop table if exists votes;
+drop table if exists activities;
+drop table if exists actors;
 drop table if exists instances;
 
 -- name: create-accounts
@@ -102,7 +105,7 @@ create table activities (
 -- this is used to store Note/Article objects that correspond to elements in the items table
 create table objects (
   "id" serial not null constraint objects_pkey primary key,
-  "key" char(32) constraint actors_key_key unique,
+  "key" char(32) constraint objects_key_key unique,
   "pub_id" varchar, -- the activitypub Object ID
   "type" varchar, -- maybe enum
   "url" varchar,

and this change to app/frontend/frontend.go:

diff --git a/app/frontend/frontend.go b/app/frontend/frontend.go
index 32d337a..2c44d2e 100644
--- a/app/frontend/frontend.go
+++ b/app/frontend/frontend.go
@@ -188,6 +188,7 @@ func Init(c Config) (handler, error) {
 		account: defaultAccount,
 		sessionKeys: loadEnvSessionKeys(),
 	}
+	c.SessionKeys = h.sessionKeys
 	if c.Logger != nil {
 		h.logger = c.Logger
 	}

Using make run or ./run.sh main.go doesn't work: it tries to contact http://localhost/... and of course there's nothing listening there -- the service is running on port 3000. My .env is

HOSTNAME=localhost
LISTEN=:3000
ENV=dev
DB_HOST=localhost
DB_NAME=littr
DB_USER=littr
DB_PASSWORD=littr
SESS_AUTH_KEY=FS5PQlDYLeEuGa0F
SESS_ENC_KEY=IQEwbq1wpGNB1FpT
GITHUB_KEY=
GITHUB_SECRET=
FACEBOOK_KEY=
FACEBOOK_SECRET=
GOOGLE_KEY=
GOOGLE_SECRET=
GITLAB_KEY=
GITLAB_SECRET=
#DISABLE_SESSIONS=1
#DISABLE_DOWNVOTING=1
#DISABLE_VOTING=1
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

If I modify app/app.go to something like

diff --git a/app/app.go b/app/app.go
index 1069202..878f753 100644
--- a/app/app.go
+++ b/app/app.go
@@ -180,9 +180,17 @@ func loadEnv(l *Application) (bool, error) {
 		l.Secure = false
 	}
 	if l.Secure {
-		l.BaseURL = fmt.Sprintf("https://%s", l.HostName)
+		if l.Port != 443 {
+			l.BaseURL = fmt.Sprintf("https://%s:%d", l.HostName, l.Port)
+		} else {
+			l.BaseURL = fmt.Sprintf("https://%s", l.HostName)
+		}
 	} else {
-		l.BaseURL = fmt.Sprintf("http://%s", l.HostName)
+		if l.Port != 80 {
+			l.BaseURL = fmt.Sprintf("http://%s:%d", l.HostName, l.Port)
+		} else {
+			l.BaseURL = fmt.Sprintf("http://%s", l.HostName)
+		}
 	}
 	if l.Config.Env = EnvType(os.Getenv("ENV")); !validEnv(l.Config.Env) {
 		l.Config.Env = DEV

I get the same layout error as in issue #1; I see a loop:

time="2019-03-02T20:51:34Z" level=info msg=Started Listen=":3000" env=dev host=localhost
time="2019-03-02T20:51:38Z" level=info msg="[GET http://localhost:3000/self/outbox?context=0&deleted=false&federated=false&maxItems=50&page=1]"
time="2019-03-02T20:51:38Z" level=info msg="[GET http://localhost:3000/self]"
time="2019-03-02T20:51:38Z" level=debug msg="showing self posts"
time="2019-03-02T20:51:38Z" level=info msg="[GET http://localhost:3000/self/outbox?context=0&deleted=false&federated=false&maxItems=50&page=1]"
time="2019-03-02T20:51:38Z" level=info msg="[GET http://localhost:3000/self]"
time="2019-03-02T20:51:38Z" level=debug msg="showing self posts"
time="2019-03-02T20:51:38Z" level=info msg="[GET http://localhost:3000/self/outbox?context=0&deleted=false&federated=false&maxItems=50&page=1]"
time="2019-03-02T20:51:38Z" level=info msg="[GET http://localhost:3000/self]"
time="2019-03-02T20:51:38Z" level=debug msg="showing self posts"

Feature requests

-Auto fetch and fill submission title based on the URL that's being input
-Add thumbnails (automatically fetched from the URL)
-Make links open in new tabs with noopener/noreferrer/nofollow
-Create a sitename config so the browser tab doesn't just display "Newest items"

Cannot start littr: "Internal Server Error - Unable to load the Service's inbox"

Hello,

I'm trying to set up fedbox and littr. After littr starts, it shows the error message

Internal Server Error
Unable to load the Service's inbox

on the homepage.

I'm on current master on both repos (commit f237ecaf0def98c3d3915f6199b025b99bee16da for fedbox, and 865ec37 on littr), running on ubuntu server 20.04 with "go version go1.13.8 linux/amd64".

I have an nginx that's reverse proxying http://fedbox.local to http://localhost:4000, and http://littr.local to http://localhost:3000. Both hosts are also in my /etc/hosts file and point to 127.0.0.1.

fedbox .env file:

HOSTNAME=fedbox.local
LISTEN=localhost:4000
ENV=dev
STORAGE=boltdb
STORAGE_PATH=/var/www/fedbox/storage/

fedbox install commands:

mkdir /var/www/fedbox/storage
./bin/ctl bootstrap
./bin/ctl ap actor add admin
./bin/ctl oauth client add --redirectUri=http://littr.local/auth/fedbox/callback

littr .env file:

HOSTNAME=fedbox.local
LISTEN_HOST=127.0.0.1
LISTEN_PORT=3000
ENV=dev
API_URL=http://fedbox.local
SESS_AUTH_KEY=...
SESS_ENC_KEY=...
# Client ID received from the "oauth client add" command
OAUTH2_KEY=192952fd-aa14-401e-9f73-215416cd426b
# Secret i entered into the "oauth client add" command
OAUTH2_SECRET=...
SESS_BACKEND=cookie
DISABLE_SESSIONS=false
DISABLE_DOWNVOTING=false
DISABLE_VOTING=false

fedbox log:

INFO[0000] Listening on localhost:4000
INFO[0005] OK                                            addr="127.0.0.1:42240" elapsed=1.357457ms id=chalet/t4IJzIHzeF-000001 len=561 method=GET proto=HTTP/1.1 scheme=http status=200 ts="Fri, 03 Jul 2020 12:38:17 UTC" ua=chalet.local-865ec37-git uri="http://fedbox.local/actors/192952fd-aa14-401e-9f73-215416cd426b"
INFO[0005] OK                                            addr="127.0.0.1:42242" elapsed=85.821488ms id=chalet/t4IJzIHzeF-000002 len=126 method=POST proto=HTTP/1.1 scheme=http status=200 ts="Fri, 03 Jul 2020 12:38:17 UTC" ua=Go-http-client/2.0 uri="http://fedbox.local/oauth/token"
INFO[0005] OK                                            addr="127.0.0.1:42244" elapsed="829.615µs" id=chalet/t4IJzIHzeF-000003 len=1561 method=GET proto=HTTP/1.1 scheme=http status=200 ts="Fri, 03 Jul 2020 12:38:17 UTC" ua=chalet.local-865ec37-git uri="http://fedbox.local/actors?type=Person&type=Service&type=Group&type=Application&type=Organization"
ERRO[0005] Not Found                                     addr="127.0.0.1:42246" elapsed=1.567971ms id=chalet/t4IJzIHzeF-000004 len=6837 method=GET proto=HTTP/1.1 scheme=http status=404 ts="Fri, 03 Jul 2020 12:38:17 UTC" ua=chalet.local-865ec37-git uri="http://fedbox.local/objects?context=-&type=Article&type=Note&type=Link&type=Page&type=Document&type=Video&type=Audio"
ERRO[0005] Not Found                                     addr="127.0.0.1:42248" elapsed=1.709308ms id=chalet/t4IJzIHzeF-000005 len=6837 method=GET proto=HTTP/1.1 scheme=http status=404 ts="Fri, 03 Jul 2020 12:38:17 UTC" ua=chalet.local-865ec37-git uri="http://fedbox.local/objects?type=Article&type=Note&type=Link&type=Page&type=Document&type=Video&type=Audio"

littr log:

ERRO[0000] https://fedbox.local/objects?context=-&type=Article&type=Note&type=Link&type=Page&type=Document&type=Video&type=Audio: Unable to load from the AP end point: invalid status 404
ERRO[0000] https://fedbox.local/objects?type=Article&type=Note&type=Link&type=Page&type=Document&type=Video&type=Audio: Unable to load from the AP end point: invalid status 404
INFO[0000] Started                                       env="" host=littr.local listen="localhost:3000"

These logs indicate that littr can talk to fedbox, but some of these requests fail with error 404 (the /objects requests). When I open littr in the browser, the internal server error appears, and the following lines are logged:

fedbox log:

ERRO[0253] Not Found                                     addr="127.0.0.1:42254" elapsed=1.509747ms id=chalet/t4IJzIHzeF-000006 len=6826 method=GET proto=HTTP/1.1 scheme=http status=404 ts="Fri, 03 Jul 2020 12:42:26 UTC" ua=littr.local-865ec37-git uri="http://fedbox.local/inbox?maxItems=25&object.context=-&object.type=Article&object.type=Note&object.type=Link&object.type=Page&object.type=Document&object.type=Video&object.type=Audio&type=Create

littr log:

ERRO[0248] http://fedbox.local/inbox?maxItems=25&object.context=-&object.type=Article&object.type=Note&object.type=Link&object.type=Page&object.type=Document&object.type=Video&object.type=Audio&type=Create: Unable to load from the AP end point: invalid status 404
INFO[0248] OK                                            duration=36.655065ms host=littr.local https=false id=chalet/Gk0eG0dQbT-000001 length=17717 met=GET proto=HTTP/1.1 status=200 uri=/

It seems to me that littr is set up correctly, but some data is missing in fedbox, so that it can't respond to the /objects and /inbox requests. Any help would be appreciated.

"Discussion" labels confusing for self-posts

Hi there!

I was checking out https://brutalinks.tech and just thought I'd report what I think is a UX issue.

Using this post as an example: https://brutalinks.tech/~HT472/a2473c7b-797e-49d8-b913-630c79d86258

When viewed on the front page, there's two links, both labeled "Discussion", but they lead to two different places.

The first appears after the post title and (I believe) leads to a page with other self-posts.

The second appears on the line with the date posted, username, etc, and leads to the individual discussion.

Load Current Account

Load all interesting information about current account - needs to define what's "interesting" from an ActivityPub point of view.

Name sounds like a shock site.

I came here from an old Hacker News thread, when this was apparently still called "Littr".

I have no idea if the tech and platform is good or bad. At a glance it looks solid.

But Old Reddit particularly was infamous for …unfortunate subreddits that would get posted around in threads at random. And certain other ungulate-themed link aggregators inspired by Reddit have previously devolved into … As Wikipedia puts it, "a hub for the alt-right […] where users compete for shock value".

So when I see a website billed as similar to Reddit, but called "BrutaLinks", I tend to think I should probably not click that, and instead avoid finding out what it is.

I don't know if this is just a "me" problem, though I hope not entirely. I also don't mean this as a criticism or attack. The site and branding on its own looks clean, and pretty usable! But this is the Internet, and the name matters for the impression that people are going to have about a platform or project.

Cleanup session save

We're currently saving to the session the whole models.Account object.

As it contains the Votes slice and the SSHKey associated with the account, the size of the session outgrows the capacity of the cookie session store.

We need to:

  • Create new type that contains the barebones data required for the account: { handle, key } and store that to session.
  • Move away from cookie store to local file storage, redis or memcache (ideally configurable with .env values)

Registration or submission fails: Error: Post "/outbox": unsupported protocol scheme ""

Call to client.ToCollection() are not including the fedbox hostname in the URL argument, resulting in http client requests failing.

littr .env:

# HOSTNAME is used as the base for the absolute URLs in the site
HOSTNAME=littr.brokedown.net
# LISTEN_PORT is the port number that the application will listen on for connections
LISTEN_PORT=3000
# LISTEN_HOST is the host/ip that the application will listen on for connections
LISTEN_HOSTNAME=littr
# ENV the environment type sets different configuration settings, valid are: DEV, QA, STAGING, PROD
ENV=DEV
# API_URL is the url of the fedbox instance that provides our C2S ActivityPub API
API_URL=http://fedbox.local
# SESS_AUTH_KEY is used for encrypting the session data
SESS_AUTH_KEY=1234567890123456
# SESS_ENC_KEY
SESS_ENC_KEY=6543210987654321
# OAUTH2_KEY the default OAuth2 key used by the frontend to connect to the C2S ActivityPub end-points
OAUTH2_KEY=8b80de04-b72b-455f-aab3-4cada26e47c5
# OAUTH2_SECRET the default OAuth2 secret used by the frontend
OAUTH2_SECRET=server
# SESSIONS_BACKEND the backend to use for session storage, valid: cookie, fs
SESSIONS_BACKEND=cookie
# DISABLE_SESSIONS setting this to true, makes the instance essentially read only, by disallowing user logins
DISABLE_SESSIONS=false
# DISABLE_DOWNVOTING disables allowing Dislike activities
DISABLE_DOWNVOTING=false
# DISABLE_VOTING disables all Like/Dislike activities
DISABLE_VOTING=false

fedbox .env:

HOSTNAME=fedbox.local
LISTEN=fedbox.local:80
ENV=dev
STORAGE=fs
STORAGE_PATH=/tmp/data/fedbox

Environment is a docker container with hosts entries for littr resolving to container's IP and others resolving to 127.0.0.1.

Improve .env.example and readme

Hello,

The comments in .env.example are good, but slightly confusing. Especially as it relates to the connection to fedbox. It's unclear how to wire the two together. Any chance these could be made clearer?

I'm happy to submit a PR to improve once I understand it fully myself - but so far I can't get it working.

Load Likes/Dislikes with filters

See #2

Use the api/liked end-point but add filtering capabilities.

AP end point filtering capabilities

  • itemKey - load for specific items

  • type - load like/dislike

  • attributedTo - load by specific accounts

  • Implement api.LoadVotes repository method.

Add fedbox docker to the setup

The two last elements still remaining from #25 are setting up docker:

  • Modify docker setup to include a FedBOX container
  • Modify bootstrap procedure to include adding an OAuth2 client for littr.go on FedBOX

Registration/login appears broken

Made a couple accounts to test, this is current behavior on littr.me

Account creation goes well, but once you try logging in, if you type the password correctly it goes through the motions and redirects you to the front page. No obvious sign that you are logged in, and if you click "Log In" again, it will bring you to the normal log in page.

If you type the password incorrectly in login, it will redirect to the login page but not give any sign that you had the wrong password.

Better threading model

I have just added pagination to item pages.

This exposed the fact that we need to improve the threading model to generate queries that bias in favour of top level items instead of recent ones that are also deep in the replies of another item.

We need to load as many as possible top level items, instead of pigeonholeing on a single item and its children just because they are the most recent.

For this I need to add a maximum depth for the path in the postgres query - which I imagine propagates transparently to the ActivityPub api responses without having to do anything extra.

Layout is undefined

I run the main.go..
Server starts up but the Web gui does not work. In the browser i get:

html/template: "layout" is undefined
html/template: "layout" is undefined

DO i need to embed the assets first ?

Link to the flagship instance on github

otherwise it's harder to understand what your project is about, also harder to check if there are any visible improvements.

See lobsters github page as an example.

Might also be good for SEO, having a higher chance it will pop up in search results.

I am assuming here this is the flagship instance.

Issue getting littr and fedbox to communicate with each other correctly

Here is what is in my .env for littr

# HOSTNAME is used as the base for the absolute URLs in the site
HOSTNAME=littr.local
# LISTEN_PORT is the port number that the application will listen on for connections
LISTEN_PORT=3000
# LISTEN_HOST is the host/ip that the application will listen on for connections
LISTEN_HOST=localhost
# ENV the environment type sets different configuration settings, valid are: DEV, QA, STAGING, PROD
ENV=dev
# API_URL is the url of the fedbox instance that provides our C2S ActivityPub API
API_URL=http://fedbox.local
# SESS_AUTH_KEY is used for encrypting the session data
SESS_AUTH_KEY=16_chars_enc_key=
# SESS_ENC_KEY
SESS_ENC_KEY=16_chars_enc_key+
# OAUTH2_KEY the default OAuth2 key used by the frontend to connect to the C2S ActivityPub end-points
OAUTH2_KEY=1e2ba133-f4a5-4182-8540-309646e9ea59
# OAUTH2_SECRET the default OAuth2 secret used by the frontend
OAUTH2_SECRET=littr
# SESSIONS_BACKEND the backend to use for session storage, valid: cookie, fs
SESSIONS_BACKEND=fs
# DISABLE_SESSIONS setting this to true, makes the instance essentially read only, by disallowing user logins
DISABLE_SESSIONS=false
# DISABLE_DOWNVOTING disables allowing Dislike activities
DISABLE_DOWNVOTING=false
# DISABLE_VOTING disables all Like/Dislike activities
DISABLE_VOTING=false

Here is what is in my fedbox .env

HOSTNAME=fedbox.local
LISTEN=localhost:4000
ENV=dev
STORAGE=fs
STORAGE_PATH=.

I have littr.local and fedbox.local setup in /etc/hosts. I also have both littr and fedbox running behind a reverse proxy using nginx.

I ran these commands for setting up fedbox:

./bin/ctl bootstrap
./bin/ctl ap actor add admin
./bin/ctl oauth client add --redirectUri http://littr.local/auth/fedbox/callback

This is what I get when I go to littr.local

2020-07-13-210544_1915x957_scrot

In the littr log I get this:

ERRO[0000] http://fedbox.local/actors/1e2ba133-f4a5-4182-8540-309646e9ea59: Unable to load from the AP end point: invalid status 404
ERRO[0000] Failed to load actor: Unable to load Actor: http://fedbox.local/actors/1e2ba133-f4a5-4182-8540-309646e9ea59
ERRO[0000] oauth2: cannot fetch token: 403 Forbidden

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.