diff --git a/README.md b/README.md index 0c534d54e..98b412955 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Front Page|Post ---|--- ![main screen](https://raw.githubusercontent.com/LemmyNet/lemmy/main/docs/img/main_screen.png)|![chat screen](https://raw.githubusercontent.com/LemmyNet/lemmy/main/docs/img/chat_screen.png) -[Lemmy](https://github.com/LemmyNet/lemmy) is similar to sites like [Reddit](https://reddit.com), [Lobste.rs](https://lobste.rs), [Raddle](https://raddle.me), or [Hacker News](https://news.ycombinator.com/): you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the [Fediverse](https://en.wikipedia.org/wiki/Fediverse). +[Lemmy](https://github.com/LemmyNet/lemmy) is similar to sites like [Reddit](https://reddit.com), [Lobste.rs](https://lobste.rs), or [Hacker News](https://news.ycombinator.com/): you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the [Fediverse](https://en.wikipedia.org/wiki/Fediverse). For a link aggregator, this means a user registered on one server can subscribe to forums on any other server, and can have discussions with users registered elsewhere. @@ -65,7 +65,7 @@ Each Lemmy server can set its own moderation policy; appointing site-wide admins - Open source, [AGPL License](/LICENSE). - Self hostable, easy to deploy. - - Comes with [Docker](#docker), [Ansible](#ansible), [Kubernetes](#kubernetes). + - Comes with [Docker](#docker) and [Ansible](#ansible). - Clean, mobile-friendly interface. - Only a minimum of a username and password is required to sign up! - User avatar support. @@ -102,7 +102,6 @@ Each Lemmy server can set its own moderation policy; appointing site-wide admins - [Docker](https://dev.lemmy.ml/docs/administration_install_docker.html) - [Ansible](https://dev.lemmy.ml/docs/administration_install_ansible.html) -- [Kubernetes](https://dev.lemmy.ml/docs/administration_install_kubernetes.html) ## Lemmy Projects @@ -152,7 +151,7 @@ If you want to help with translating, take a look at [Weblate](https://weblate.y - [GitHub](https://github.com/LemmyNet/lemmy) - [Gitea](https://yerbamate.dev/LemmyNet/lemmy) -- [GitLab](https://gitlab.com/dessalines/lemmy) +- [Codeberg](https://codeberg.org/LemmyNet/lemmy) ## Credits diff --git a/ansible/lemmy.yml b/ansible/lemmy.yml index b4187158f..28179ba41 100644 --- a/ansible/lemmy.yml +++ b/ansible/lemmy.yml @@ -79,6 +79,7 @@ lemmy_docker_image: "dessalines/lemmy:{{ lookup('file', 'VERSION') }}" lemmy_docker_ui_image: "dessalines/lemmy-ui:{{ lookup('file', 'VERSION') }}" lemmy_port: "8536" + lemmy_ui_port: "1235" pictshare_port: "8537" iframely_port: "8538" diff --git a/ansible/templates/nginx.conf b/ansible/templates/nginx.conf index 7f13259ad..03b139bb0 100644 --- a/ansible/templates/nginx.conf +++ b/ansible/templates/nginx.conf @@ -57,6 +57,10 @@ server { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # The default ports: + # lemmy_ui_port: 1235 + # lemmy_port: 8536 + set $proxpass "http://0.0.0.0:{{ lemmy_ui_port }}"; if ($http_accept = "application/activity+json") { set $proxpass "http://0.0.0.0:{{ lemmy_port }}"; diff --git a/api_tests/package.json b/api_tests/package.json index ec16cac66..5c7cd3eb7 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -12,9 +12,9 @@ "devDependencies": { "@types/jest": "^26.0.14", "jest": "^26.4.2", - "lemmy-js-client": "^1.0.13", + "lemmy-js-client": "^1.0.14", "node-fetch": "^2.6.1", - "ts-jest": "^26.4.0", + "ts-jest": "^26.4.1", "typescript": "^4.0.3" } } diff --git a/api_tests/yarn.lock b/api_tests/yarn.lock index e0def58b6..e1ee01ac3 100644 --- a/api_tests/yarn.lock +++ b/api_tests/yarn.lock @@ -2360,10 +2360,10 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== -lemmy-js-client@^1.0.13: - version "1.0.13" - resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.13.tgz#d0e1246129ade295faeec1fb4b2c7397d6947a19" - integrity sha512-Xz87cCswi/2pbDdApw9JIy8bDWRFGiGWO6IhehTytOAzf36dr4GYgsjTQTLjBX+s+BNYr8hE0+Sz4g9c+ynoJg== +lemmy-js-client@^1.0.14: + version "1.0.14" + resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.14.tgz#81a847dd0c7d97c83913f198717498c223dc371e" + integrity sha512-hiGxAnAD5RFmE8qHMBtYNNYD/UrfCZ5JzmVEH/i5Vg/v5i/ZVmebx20uWtRMmdSSy6s4GbW0w4niszLW6SaJ3Q== leven@^3.1.0: version "3.1.0" @@ -3382,10 +3382,10 @@ tr46@^2.0.2: dependencies: punycode "^2.1.1" -ts-jest@^26.4.0: - version "26.4.0" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.0.tgz#903c7827f3d3bc33efc2f91be294b164400c32e3" - integrity sha512-ofBzoCqf6Nv/PoWb/ByV3VNKy2KJSikamOBxvR3E6eVdIw10GwAXoyvMWXXjZJK2s6S27ZE8fI+JBTnGaovl6Q== +ts-jest@^26.4.1: + version "26.4.1" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.1.tgz#08ec0d3fc2c3a39e4a46eae5610b69fafa6babd0" + integrity sha512-F4aFq01aS6mnAAa0DljNmKr/Kk9y4HVZ1m6/rtJ0ED56cuxINGq3Q9eVAh+z5vcYKe5qnTMvv90vE8vUMFxomg== dependencies: "@types/jest" "26.x" bs-logger "0.x" diff --git a/docker/k8s/db.yml b/docker/k8s/db.yml deleted file mode 100644 index 4b78a8c58..000000000 --- a/docker/k8s/db.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - labels: - lemmy.service: db - name: db -spec: - replicas: 1 - strategy: - type: Recreate - template: - metadata: - labels: - lemmy.service: db - spec: - containers: - - env: - - name: POSTGRES_DB - value: lemmy - - name: POSTGRES_PASSWORD - # example: very-good-password - value: CHANGE_ME - - name: POSTGRES_USER - value: lemmy - image: postgres:12-alpine - name: db - volumeMounts: - - mountPath: /var/lib/postgresql/data - name: db - restartPolicy: Always - volumes: - - name: db - persistentVolumeClaim: - claimName: db ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - labels: - lemmy.service: db - name: db -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 20Gi diff --git a/docker/k8s/lemmy.yml b/docker/k8s/lemmy.yml deleted file mode 100644 index 8e105d605..000000000 --- a/docker/k8s/lemmy.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - labels: - lemmy.service: lemmy - name: lemmy -spec: - replicas: 1 - template: - metadata: - labels: - lemmy.service: lemmy - spec: - containers: - - env: - - name: LEMMY_DATABASE_URL - # example: 'postgres://lemmy:password@db:5432/lemmy' - value: CHANGE_ME - - name: LEMMY_HOSTNAME - # example: 'lemmy.example.com' - value: CHANGE_ME - - name: LEMMY_JWT_SECRET - # example: 'very-super-good-secret' - value: CHANGE_ME - - name: LEMMY_FRONT_END_DIR - value: /app/dist - image: dessalines/lemmy:v0.2.0.1 - name: lemmy - ports: - - containerPort: 8536 - restartPolicy: Always ---- -apiVersion: v1 -kind: Service -metadata: - labels: - lemmy.service: lemmy - name: lemmy -spec: - ports: - - name: "8536" - port: 8536 - targetPort: 8536 - selector: - lemmy.service: lemmy diff --git a/docker/k8s/pictshare.yml b/docker/k8s/pictshare.yml deleted file mode 100644 index 1209e83ec..000000000 --- a/docker/k8s/pictshare.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - labels: - lemmy.service: pictshare - name: pictshare -spec: - replicas: 1 - strategy: - type: Recreate - template: - metadata: - labels: - lemmy.service: pictshare - spec: - containers: - - image: hascheksolutions/pictshare:latest - name: pictshare - ports: - - containerPort: 80 - volumeMounts: - - mountPath: /usr/share/nginx/html/data - name: pictshare - restartPolicy: Always - volumes: - - name: pictshare - persistentVolumeClaim: - claimName: pictshare ---- -apiVersion: v1 -kind: Service -metadata: - labels: - lemmy.service: pictshare - name: pictshare -spec: - ports: - - name: "8537" - port: 8537 - targetPort: 80 - selector: - lemmy.service: pictshare -status: ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - labels: - lemmy.service: pictshare - name: pictshare -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 20Gi diff --git a/docker/prod/deploy.sh b/docker/prod/deploy.sh index 7d84738b2..81bfdab8e 100755 --- a/docker/prod/deploy.sh +++ b/docker/prod/deploy.sh @@ -1,10 +1,10 @@ #!/bin/sh set -e -git checkout main +#git checkout main # Creating the new tag new_tag="$1" -third_semver=$(echo $new_tag | cut -d "." -f 3) +#third_semver=$(echo $new_tag | cut -d "." -f 3) # Setting the version on the front end cd ../../ @@ -17,12 +17,16 @@ git add "ansible/VERSION" cd docker/prod || exit -# Changing the docker-compose prod +# Changing various references to the Lemmy version +sed -i "s/dessalines\/lemmy-ui:.*/dessalines\/lemmy-ui:$new_tag/" ../dev/docker-compose.yml +sed -i "s/dessalines\/lemmy-ui:.*/dessalines\/lemmy-ui:$new_tag/" ../federation/docker-compose.yml sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../prod/docker-compose.yml -sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../../ansible/templates/docker-compose.yml +sed -i "s/dessalines\/lemmy-ui:.*/dessalines\/lemmy-ui:$new_tag/" ../prod/docker-compose.yml sed -i "s/dessalines\/lemmy:v.*/dessalines\/lemmy:$new_tag/" ../travis/docker_push.sh + +git add ../dev/docker-compose.yml +git add ../federation/docker-compose.yml git add ../prod/docker-compose.yml -git add ../../ansible/templates/docker-compose.yml git add ../travis/docker_push.sh # The commit diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index a2bf58569..e00f5ced6 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -8,15 +8,16 @@ - [Administration](administration.md) - [Install with Docker](administration_install_docker.md) - [Install with Ansible](administration_install_ansible.md) - - [Install with Kubernetes](administration_install_kubernetes.md) - [Configuration](administration_configuration.md) - [Backup and Restore](administration_backup_and_restore.md) + - [Federation](administration_federation.md) - [Contributing](contributing.md) - [Docker Development](contributing_docker_development.md) - [Local Development](contributing_local_development.md) - [Tests](contributing_tests.md) - [Federation Development](contributing_federation_development.md) - [Websocket/HTTP API](contributing_websocket_http_api.md) + - [Federation Overview](contributing_federation_overview.md) - [ActivityPub API Outline](contributing_apub_api_outline.md) - [Theming Guide](contributing_theming.md) - [Lemmy Council](lemmy_council.md) diff --git a/docs/src/about_features.md b/docs/src/about_features.md index 7c8d95a96..ebf712e59 100644 --- a/docs/src/about_features.md +++ b/docs/src/about_features.md @@ -2,7 +2,7 @@ - Open source, [AGPL License](/LICENSE). - Self hostable, easy to deploy. - - Comes with [Docker](#docker), [Ansible](#ansible), [Kubernetes](#kubernetes). + - Comes with [Docker](#docker) and [Ansible](#ansible). - Clean, mobile-friendly interface. - Only a minimum of a username and password is required to sign up! - User avatar support. diff --git a/docs/src/administration.md b/docs/src/administration.md index 9851232d9..690b71596 100644 --- a/docs/src/administration.md +++ b/docs/src/administration.md @@ -1,3 +1,11 @@ -# Admin info +# Administration info -Information for Lemmy instance admins, and those who want to start an instance. +Information for Lemmy instance admins, and those who want to run a server. + +## Install + +Lemmy has two primary install methods, [docker](administration_install_docker.md), and [ansible](administration_install_ansible.md). Ansible simplifies deploying to a remote server, while docker is best for local testing. + +### Manual install + +Manual installs are *possible*, but not preferred, since Lemmy is dependent on other local services: The [lemmy-ui](https://github.com/LemmyNet/lemmy-ui), [a Postgresql Database](https://www.postgresql.org/), [pict-rs](https://git.asonix.dog/asonix/pict-rs/) for images, and [iframely](https://iframely.com/) for embeds. To see how these are wired together, look at the docker-compose.yml files. Due to the complexity of different systems, we will not support manual installs. diff --git a/docs/src/administration_federation.md b/docs/src/administration_federation.md new file mode 100644 index 000000000..5dc0b1a2e --- /dev/null +++ b/docs/src/administration_federation.md @@ -0,0 +1,27 @@ +# Federation + +Note: ActivityPub federation is still under development. We recommend that you only enable it on test instances for now. + +To enable federation, change the setting `federation.enabled` to `true` in `lemmy.hjson`, and restart Lemmy. + +Federation does not start automatically, but needs to be triggered manually through the search. To do this you have to enter a reference to a remote object, such as: + +- `!main@dev.lemmy.ml` (Community) +- `@nutomic@dev.lemmy.ml` (User) +- `https://dev.lemmy.ml/c/programming` (Community) +- `https://dev.lemmy.ml/u/nutomic` (User) +- `https://dev.lemmy.ml/post/123` (Post) + +For an overview of how federation in Lemmy works on a technical level, check out our [Federation Overview](contributing_federation_overview.md). + +## Instance allowlist and blocklist + +The federation section of Lemmy's config has two variables `allowed_instances` and `blocked_instances`. These control which other instances Lemmy will federate with. Both settings take a comma separated list of domains, eg `dev.lemmy.ml, example.com`. You can either change those settings via `/admin`, or directly on the server filesystem. + +It is important to note that these settings only affect sending and receiving of data between instances. If allow federation with a certain instance, and then remove it from the allowlist, this will not affect previously federated data. These communities, users, posts and comments will still be shown. They will just not be updated anymore. And even if an instance is blocked, it can still fetch and display public data from your instance. + +By default, both `allowed_instances` and `blocked_instances` values are empty, which means that Lemmy will federate with every compatible instance. We do not recommend this, because the moderation tools are not yet ready to deal with malicious instances. + +What we do recommend is putting a list of trusted instances into `allowed_instances`, and only federating with those. Note that both sides need to add each other to their `allowed_instances` to allow two-way federation. + +Alternatively you can also use blocklist based federation. In this case, add the domains of instances you do *not* want to federate with. You can only set one of `allowed_instances` and `blocked_instances`, as setting both doesn't make sense. diff --git a/docs/src/administration_install_docker.md b/docs/src/administration_install_docker.md index 311655a36..490fe1c01 100644 --- a/docs/src/administration_install_docker.md +++ b/docs/src/administration_install_docker.md @@ -25,15 +25,21 @@ Open up your `docker-compose.yml`, and make sure `LEMMY_EXTERNAL_HOST` for `lemm - LEMMY_HTTPS=false ``` +If you'd like a different database password, you should also change it in the `docker-compose.yml` **before** your first run. + After this, have a look at the [config file](administration_configuration.md) named `lemmy.hjson`, and adjust it, in particular the hostname, and possibly the db password. Then run: `docker-compose up -d` +You can access the lemmy-ui at `http://localhost:1235` + To make Lemmy available outside the server, you need to setup a reverse proxy, like Nginx. [A sample nginx config](https://raw.githubusercontent.com/LemmyNet/lemmy/main/ansible/templates/nginx.conf), could be setup with: ```bash wget https://raw.githubusercontent.com/LemmyNet/lemmy/main/ansible/templates/nginx.conf # Replace the {{ vars }} +# The default lemmy_port is 8536 +# The default lemmy_ui_port is 1235 sudo mv nginx.conf /etc/nginx/sites-enabled/lemmy.conf ``` diff --git a/docs/src/administration_install_kubernetes.md b/docs/src/administration_install_kubernetes.md deleted file mode 100644 index 729cb1558..000000000 --- a/docs/src/administration_install_kubernetes.md +++ /dev/null @@ -1,24 +0,0 @@ -# Kubernetes Installation - -You'll need to have an existing Kubernetes cluster and [storage class](https://kubernetes.io/docs/concepts/storage/storage-classes/). -Setting this up will vary depending on your provider. -To try it locally, you can use [MicroK8s](https://microk8s.io/) or [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/). - -Once you have a working cluster, edit the environment variables and volume sizes in `docker/k8s/*.yml`. -You may also want to change the service types to use `LoadBalancer`s depending on where you're running your cluster (add `type: LoadBalancer` to `ports)`, or `NodePort`s. -By default they will use `ClusterIP`s, which will allow access only within the cluster. See the [docs](https://kubernetes.io/docs/concepts/services-networking/service/) for more on networking in Kubernetes. - -**Important** Running a database in Kubernetes will work, but is generally not recommended. -If you're deploying on any of the common cloud providers, you should consider using their managed database service instead (RDS, Cloud SQL, Azure Databse, etc.). - -Now you can deploy: - -```bash -# Add `-n foo` if you want to deploy into a specific namespace `foo`; -# otherwise your resources will be created in the `default` namespace. -kubectl apply -f docker/k8s/db.yml -kubectl apply -f docker/k8s/pictshare.yml -kubectl apply -f docker/k8s/lemmy.yml -``` - -If you used a `LoadBalancer`, you should see it in your cloud provider's console. diff --git a/docs/src/contributing.md b/docs/src/contributing.md index 02eb91774..e9c7b9ea1 100644 --- a/docs/src/contributing.md +++ b/docs/src/contributing.md @@ -6,7 +6,7 @@ Information about contributing to Lemmy, whether it is translating, testing, des - [GitHub (for issues and pull requests)](https://github.com/LemmyNet/lemmy) - [Gitea (only for pull requests)](https://yerbamate.dev/LemmyNet/lemmy) -- [GitLab (only code-mirror)](https://gitlab.com/dessalines/lemmy) +- [Codeberg](https://codeberg.org/LemmyNet/lemmy) ## Translating diff --git a/docs/src/contributing_apub_api_outline.md b/docs/src/contributing_apub_api_outline.md index e2776308f..4ee2636ed 100644 --- a/docs/src/contributing_apub_api_outline.md +++ b/docs/src/contributing_apub_api_outline.md @@ -1,5 +1,7 @@ # Activitypub API outline +**This document is completely outdated and doesn't reflect the current state of Lemmy at all** + - Start with the [reddit API](https://www.reddit.com/dev/api), and find [Activitypub vocab](https://www.w3.org/TR/activitystreams-vocabulary/) to match it. diff --git a/docs/src/contributing_docker_development.md b/docs/src/contributing_docker_development.md index 586055a06..b3f113337 100644 --- a/docs/src/contributing_docker_development.md +++ b/docs/src/contributing_docker_development.md @@ -11,8 +11,8 @@ git clone https://github.com/LemmyNet/lemmy ## Running ```bash -cd lemmy/docker/dev -sudo docker-compose up --no-deps --build +cd /docker/dev +./docker_update.sh ``` and go to http://localhost:1235. diff --git a/docs/src/contributing_federation_overview.md b/docs/src/contributing_federation_overview.md new file mode 100644 index 000000000..8ed544291 --- /dev/null +++ b/docs/src/contributing_federation_overview.md @@ -0,0 +1,127 @@ +# Federation + + +This document is targeted at people that are more or less familiar with ActivityStreams and ActivityPub protocols. It is meant provide a high-level overview of ActivityPub federation in Lemmy. If you are implementing ActivityPub yourself and want to be compatible with Lemmy, read our [ActivityPub API outline](contributing_apub_api_outline.md). + +## Documentation conventions + +To keep things simple, sometimes you will see things formatted like `Create/Note` or `Delete/Event` or `Undo/Follow`. The thing before the slash is the Activity, and the thing after the slash is the Object inside the Activity, in an `object` property. So these are to be read as follows: + +* `Create/Note`: a `Create` activity containing a `Note` in the `object` field +* `Delete/Event`: a `Delete` activity containing an `Event` in the `object` field +* `Undo/Follow`: an `Undo` activity containing a `Follow` in the `object` field + +In Lemmy we use some specific terms to refer to ActivityPub items. They are essentially our specific implementations of well-known ActivityPub concepts: + +- Community: `Group` +- User: `Person` +- Post: `Page` +- Comment: `Note` + +This document has three main sections: + +* __Federation philosophy__ lays out the general model of how this is intended to federate +* __User Activities__ describes which actions that a User can take to interact +* __Community Activities__ describes what the Community does in response to certain User actions + +## Federation philosophy + +The primary Actor in Lemmy is the Community. Each community resides on a single instance, and consists of a list of Posts and a list of followers. The primary interaction is that of a User sending a Post or Comment related activity to the Community inbox, which then announces it to all its followers. + +Each Community has a specific creator User, who is responsible for setting rules, appointing moderators, and removing content that violates the rules. + +Besides moderation on the community level, each instance has a set of administrator Users, who have the power to do site-wide removals and bans. + +Users follow Communities that they are interested in, in order to receive Posts and Comments. They also vote on Posts and Comments, as well as creating new ones. Comments are organised in a tree structure and commonly sorted by number of votes. Direct messages between Users are also supported. + +Users can not follow each other, and neither can Communities follow anything. + +Our federation implementation is already feature complete, but so far we haven't focused at all on complying with the ActivityPub spec. As such, Lemmy is likely not compatible with implementations which expect to send and receive valid activities. This is something we plan to fix in the near future. Check out [#698](https://github.com/LemmyNet/lemmy/issues/698) for an overview of our deviations. + +## User Activities + +### Follow a Community + +Each Community page has a "Follow" button. Clicking this triggers a `Follow` activity to be sent from the user to the Community inbox. The Community will automatically respond with an `Accept/Follow` activity to the user inbox. It will also add the user to its list of followers, and deliver any activities about Posts/Comments in the Community to the user. + +### Unfollow a Community + +After following a Community, the "Follow" button is replaced by "Unfollow". Clicking this sends an `Undo/Follow` activity to the Community inbox. The Community removes the User from its followers list and doesn't send any activities to it anymore. + +### Create a Post + +When a user creates a new Post in a given Community, it is sent as `Create/Page` to the Community +inbox. + +### Create a Comment + +When a new Comment is created for a Post, both the Post ID and the parent Comment ID (if it exists) +are written to the `in_reply_to` field. This allows assigning it to the correct Post, and building +the Comment tree. It is then sent to the Community inbox as `Create/Note` + +The origin instance also scans the Comment for any User mentions, and sends the `Create/Note` to +those Users as well. + +### Edit a Post + +Changes the content of an existing Post. Can only be done by the creating User. + +### Edit a Comment + +Changes the content of an existing Comment. Can only be done by the creating User. + +### Likes and Dislikes + +Users can like or dislike any Post or Comment. These are sent as `Like/Page`, `Dislike/Note` etc to the Community inbox. + +### Deletions + +The creator of a Post, Comment or Community can delete it. It is then sent to the Community followers. The item is then hidden from all users. + +### Removals + +Mods can remove Posts and Comments from their Communities. Admins can remove any Posts or Comments on the entire site. Communities can also be removed by admins. The item is then hidden from all users. + +Removals are sent to all followers of the Community, so that they also take effect there. The exception is if an admin removes an item from a Community which is hosted on a different instance. In this case, the removal only takes effect locally. + +### Revert a previous Action + +We don't delete anything from our database, just hide it from users. Deleted or removed Communities/Posts/Comments have a "restore" button. This button generates an `Undo` activity which sets the original delete/remove activity as object, such as `Undo/Remove/Post` or `Undo/Delete/Community`. + +Clicking on the upvote button of an already upvoted post/comment (or the downvote button of an already downvoted post/comment) also generates an `Undo`. In this case and `Undo/Like/Post` or `Undo/Dislike/Comment`. + +### Create private message + +User profiles have a "Send Message" button, which opens a dialog permitting to send a private message to this user. It is sent as a `Create/Note` to the user inbox. Private messages can only be directed at a single User. + +### Edit private message + +`Update/Note` changes the text of a previously sent message + +### Delete private message + +`Delete/Note` deletes a private message. + +### Restore private message + +`Undo/Delete/Note` reverts the deletion of a private message. + +## Community Activities + +The Community is essentially a bot, which will only do anything in reaction to actions from Users. The User who first created the Community becomes the first moderator, and can add additional moderators. In general, whenever the Community receives a valid activity in its inbox, that activity is forwarded to all its followers. + +### Accept follow + +If the Community receives a `Follow` activity, it automatically responds with `Accept/Follow`. It also adds the User to its list of followers. + +### Unfollow + +Upon receiving an `Undo/Follow`, the Community removes the User from its followers list. + +### Announce + +If the Community receives any Post or Comment related activity (Create, Update, Like, Dislike, Remove, Delete, Undo), it will Announce this to its followers. For this, an Announce is created with the Community as actor, and the received activity as object. Following instances thus stay updated about any actions in Communities they follow. + +### Delete Community + +If the creator or an admin deletes the Community, it sends a `Delete/Group` to all its followers. diff --git a/docs/src/contributing_local_development.md b/docs/src/contributing_local_development.md index 5f53d3374..cf7049bdc 100644 --- a/docs/src/contributing_local_development.md +++ b/docs/src/contributing_local_development.md @@ -36,6 +36,9 @@ cargo build ### Get the front end source code ``` git clone https://github.com/LemmyNet/lemmy-ui.git +# get the translations +git submodule init +git submodule update --remote ``` ### Setup postgresql @@ -78,7 +81,7 @@ yarn yarn dev ``` -and goto [localhost:1234](http://localhost:1234). Front end saves should rebuild the project. +and go to [localhost:1234](http://localhost:1234). Front end saves should rebuild the project. Note that this setup doesn't include image uploads or link previews (provided by pict-rs and iframely respectively). If you want to test those, you should use the diff --git a/docs/src/contributing_websocket_http_api.md b/docs/src/contributing_websocket_http_api.md index ca2cceba6..225db0bf7 100644 --- a/docs/src/contributing_websocket_http_api.md +++ b/docs/src/contributing_websocket_http_api.md @@ -921,6 +921,7 @@ Search types are `All, Comments, Posts, Communities, Users, Url` q: String, type_: String, community_id: Option, + community_name: Option, sort: String, page: Option, limit: Option, diff --git a/lemmy_api/src/site.rs b/lemmy_api/src/site.rs index 34bdd096e..6d504f267 100644 --- a/lemmy_api/src/site.rs +++ b/lemmy_api/src/site.rs @@ -357,6 +357,7 @@ impl Perform for Search { let limit = data.limit; let sort = SortType::from_str(&data.sort)?; let community_id = data.community_id; + let community_name = data.community_name.to_owned(); match type_ { SearchType::Posts => { posts = blocking(context.pool(), move |conn| { @@ -364,6 +365,7 @@ impl Perform for Search { .sort(&sort) .show_nsfw(true) .for_community_id(community_id) + .for_community_name(community_name) .search_term(q) .my_user_id(user_id) .page(page) @@ -412,6 +414,7 @@ impl Perform for Search { .sort(&sort) .show_nsfw(true) .for_community_id(community_id) + .for_community_name(community_name) .search_term(q) .my_user_id(user_id) .page(page) @@ -466,6 +469,7 @@ impl Perform for Search { .sort(&sort) .show_nsfw(true) .for_community_id(community_id) + .for_community_name(community_name) .url_search(q) .page(page) .limit(limit) diff --git a/lemmy_api/src/user.rs b/lemmy_api/src/user.rs index 4324c9368..72f87789a 100644 --- a/lemmy_api/src/user.rs +++ b/lemmy_api/src/user.rs @@ -117,6 +117,11 @@ impl Perform for Register { } } + // Password length check + if data.password.len() > 60 { + return Err(APIError::err("invalid_password").into()); + } + // Make sure passwords match if data.password != data.password_verify { return Err(APIError::err("passwords_dont_match").into()); @@ -172,7 +177,7 @@ impl Perform for Register { admin: data.admin, banned: false, show_nsfw: data.show_nsfw, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Active as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_apub/src/comment.rs b/lemmy_apub/src/comment.rs index 33ad1d8a1..e06fe71ea 100644 --- a/lemmy_apub/src/comment.rs +++ b/lemmy_apub/src/comment.rs @@ -36,6 +36,7 @@ use activitystreams::{ }; use actix_web::{body::Body, web, web::Path, HttpResponse}; use anyhow::Context; +use diesel::result::Error::NotFound; use itertools::Itertools; use lemmy_db::{ comment::{Comment, CommentForm}, @@ -69,6 +70,9 @@ pub async fn get_apub_comment( ) -> Result, LemmyError> { let id = info.comment_id.parse::()?; let comment = blocking(context.pool(), move |conn| Comment::read(conn, id)).await??; + if !comment.local { + return Err(NotFound.into()); + } if !comment.deleted { Ok(create_apub_response( diff --git a/lemmy_apub/src/inbox/community_inbox.rs b/lemmy_apub/src/inbox/community_inbox.rs index d979e27fe..e4ee7b375 100644 --- a/lemmy_apub/src/inbox/community_inbox.rs +++ b/lemmy_apub/src/inbox/community_inbox.rs @@ -57,6 +57,10 @@ pub async fn community_inbox( .into(), ); } + debug!( + "Community {} received activity {:?}", + &community.name, &activity + ); let user_uri = activity .actor()? .as_single_xsd_any_uri() diff --git a/lemmy_apub/src/post.rs b/lemmy_apub/src/post.rs index 2d615ea1b..8dd8357dc 100644 --- a/lemmy_apub/src/post.rs +++ b/lemmy_apub/src/post.rs @@ -32,6 +32,7 @@ use activitystreams::{ use activitystreams_ext::Ext1; use actix_web::{body::Body, web, HttpResponse}; use anyhow::Context; +use diesel::result::Error::NotFound; use lemmy_db::{ community::Community, post::{Post, PostForm}, @@ -62,6 +63,9 @@ pub async fn get_apub_post( ) -> Result, LemmyError> { let id = info.post_id.parse::()?; let post = blocking(context.pool(), move |conn| Post::read(conn, id)).await??; + if !post.local { + return Err(NotFound.into()); + } if !post.deleted { Ok(create_apub_response(&post.to_apub(context.pool()).await?)) diff --git a/lemmy_db/src/activity.rs b/lemmy_db/src/activity.rs index 6830d566d..37f86c4bd 100644 --- a/lemmy_db/src/activity.rs +++ b/lemmy_db/src/activity.rs @@ -109,7 +109,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/comment.rs b/lemmy_db/src/comment.rs index 398ea78bf..02c84187e 100644 --- a/lemmy_db/src/comment.rs +++ b/lemmy_db/src/comment.rs @@ -284,7 +284,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/comment_view.rs b/lemmy_db/src/comment_view.rs index a3358ac43..568083ce9 100644 --- a/lemmy_db/src/comment_view.rs +++ b/lemmy_db/src/comment_view.rs @@ -523,7 +523,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/community.rs b/lemmy_db/src/community.rs index 24cf7e32f..f733a4d6f 100644 --- a/lemmy_db/src/community.rs +++ b/lemmy_db/src/community.rs @@ -87,6 +87,7 @@ impl Community { pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result { use crate::schema::community::dsl::*; community + .filter(local) .filter(name.eq(community_name)) .first::(conn) } @@ -329,7 +330,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/moderator.rs b/lemmy_db/src/moderator.rs index 3edd4350f..fb74def08 100644 --- a/lemmy_db/src/moderator.rs +++ b/lemmy_db/src/moderator.rs @@ -420,7 +420,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), @@ -449,7 +449,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/password_reset_request.rs b/lemmy_db/src/password_reset_request.rs index 8a831a8db..20db73ec5 100644 --- a/lemmy_db/src/password_reset_request.rs +++ b/lemmy_db/src/password_reset_request.rs @@ -104,7 +104,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/post.rs b/lemmy_db/src/post.rs index 724c342c6..41401431b 100644 --- a/lemmy_db/src/post.rs +++ b/lemmy_db/src/post.rs @@ -353,7 +353,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/post_view.rs b/lemmy_db/src/post_view.rs index 8f606b226..91c1bff53 100644 --- a/lemmy_db/src/post_view.rs +++ b/lemmy_db/src/post_view.rs @@ -273,12 +273,10 @@ impl<'a> PostQueryBuilder<'a> { if let Some(for_community_id) = self.for_community_id { query = query.filter(community_id.eq(for_community_id)); - query = query.then_order_by(stickied.desc()); } if let Some(for_community_name) = self.for_community_name { query = query.filter(community_name.eq(for_community_name)); - query = query.then_order_by(stickied.desc()); } if let Some(url_search) = self.url_search { @@ -292,6 +290,8 @@ impl<'a> PostQueryBuilder<'a> { .or_filter(body.ilike(searcher)); } + query = query.then_order_by(stickied.desc()); + query = match self.sort { SortType::Active => query .then_order_by(hot_rank_active.desc()) @@ -418,7 +418,7 @@ mod tests { admin: false, banned: false, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/private_message.rs b/lemmy_db/src/private_message.rs index 988d97d3b..4775ceba2 100644 --- a/lemmy_db/src/private_message.rs +++ b/lemmy_db/src/private_message.rs @@ -161,7 +161,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), @@ -190,7 +190,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/user.rs b/lemmy_db/src/user.rs index 83f0559ab..1f0a42ffb 100644 --- a/lemmy_db/src/user.rs +++ b/lemmy_db/src/user.rs @@ -144,11 +144,17 @@ impl User_ { } pub fn find_by_username(conn: &PgConnection, username: &str) -> Result { - user_.filter(name.ilike(username)).first::(conn) + user_ + .filter(local) + .filter(name.ilike(username)) + .first::(conn) } pub fn find_by_email(conn: &PgConnection, from_email: &str) -> Result { - user_.filter(email.eq(from_email)).first::(conn) + user_ + .filter(local) + .filter(email.eq(from_email)) + .first::(conn) } pub fn get_profile_url(&self, hostname: &str) -> String { @@ -191,7 +197,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), @@ -221,7 +227,7 @@ mod tests { published: inserted_user.published, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_db/src/user_mention.rs b/lemmy_db/src/user_mention.rs index f35722cf9..79f93801a 100644 --- a/lemmy_db/src/user_mention.rs +++ b/lemmy_db/src/user_mention.rs @@ -100,7 +100,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), @@ -129,7 +129,7 @@ mod tests { published: None, updated: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(), diff --git a/lemmy_structs/src/site.rs b/lemmy_structs/src/site.rs index b82b325e3..3f185928b 100644 --- a/lemmy_structs/src/site.rs +++ b/lemmy_structs/src/site.rs @@ -23,6 +23,7 @@ pub struct Search { pub q: String, pub type_: String, pub community_id: Option, + pub community_name: Option, pub sort: String, pub page: Option, pub limit: Option, diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 4edaefac5..f7b32151e 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -88,7 +88,7 @@ fn create_user(conn: &PgConnection, name: &str) -> User_ { updated: None, published: None, show_nsfw: false, - theme: "darkly".into(), + theme: "browser".into(), default_sort_type: SortType::Hot as i16, default_listing_type: ListingType::Subscribed as i16, lang: "browser".into(),