Merge branch 'main' into no_conflict_triggers

This commit is contained in:
Dessalines 2020-10-07 20:57:29 -05:00
commit c08d891742
39 changed files with 260 additions and 223 deletions

View file

@ -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) ![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. 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). - Open source, [AGPL License](/LICENSE).
- Self hostable, easy to deploy. - Self hostable, easy to deploy.
- Comes with [Docker](#docker), [Ansible](#ansible), [Kubernetes](#kubernetes). - Comes with [Docker](#docker) and [Ansible](#ansible).
- Clean, mobile-friendly interface. - Clean, mobile-friendly interface.
- Only a minimum of a username and password is required to sign up! - Only a minimum of a username and password is required to sign up!
- User avatar support. - 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) - [Docker](https://dev.lemmy.ml/docs/administration_install_docker.html)
- [Ansible](https://dev.lemmy.ml/docs/administration_install_ansible.html) - [Ansible](https://dev.lemmy.ml/docs/administration_install_ansible.html)
- [Kubernetes](https://dev.lemmy.ml/docs/administration_install_kubernetes.html)
## Lemmy Projects ## 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) - [GitHub](https://github.com/LemmyNet/lemmy)
- [Gitea](https://yerbamate.dev/LemmyNet/lemmy) - [Gitea](https://yerbamate.dev/LemmyNet/lemmy)
- [GitLab](https://gitlab.com/dessalines/lemmy) - [Codeberg](https://codeberg.org/LemmyNet/lemmy)
## Credits ## Credits

View file

@ -79,6 +79,7 @@
lemmy_docker_image: "dessalines/lemmy:{{ lookup('file', 'VERSION') }}" lemmy_docker_image: "dessalines/lemmy:{{ lookup('file', 'VERSION') }}"
lemmy_docker_ui_image: "dessalines/lemmy-ui:{{ lookup('file', 'VERSION') }}" lemmy_docker_ui_image: "dessalines/lemmy-ui:{{ lookup('file', 'VERSION') }}"
lemmy_port: "8536" lemmy_port: "8536"
lemmy_ui_port: "1235"
pictshare_port: "8537" pictshare_port: "8537"
iframely_port: "8538" iframely_port: "8538"

View file

@ -57,6 +57,10 @@ server {
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 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 }}"; set $proxpass "http://0.0.0.0:{{ lemmy_ui_port }}";
if ($http_accept = "application/activity+json") { if ($http_accept = "application/activity+json") {
set $proxpass "http://0.0.0.0:{{ lemmy_port }}"; set $proxpass "http://0.0.0.0:{{ lemmy_port }}";

View file

@ -12,9 +12,9 @@
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.14", "@types/jest": "^26.0.14",
"jest": "^26.4.2", "jest": "^26.4.2",
"lemmy-js-client": "^1.0.13", "lemmy-js-client": "^1.0.14",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"ts-jest": "^26.4.0", "ts-jest": "^26.4.1",
"typescript": "^4.0.3" "typescript": "^4.0.3"
} }
} }

View file

@ -2360,10 +2360,10 @@ kleur@^3.0.3:
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==
lemmy-js-client@^1.0.13: lemmy-js-client@^1.0.14:
version "1.0.13" version "1.0.14"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.13.tgz#d0e1246129ade295faeec1fb4b2c7397d6947a19" resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.14.tgz#81a847dd0c7d97c83913f198717498c223dc371e"
integrity sha512-Xz87cCswi/2pbDdApw9JIy8bDWRFGiGWO6IhehTytOAzf36dr4GYgsjTQTLjBX+s+BNYr8hE0+Sz4g9c+ynoJg== integrity sha512-hiGxAnAD5RFmE8qHMBtYNNYD/UrfCZ5JzmVEH/i5Vg/v5i/ZVmebx20uWtRMmdSSy6s4GbW0w4niszLW6SaJ3Q==
leven@^3.1.0: leven@^3.1.0:
version "3.1.0" version "3.1.0"
@ -3382,10 +3382,10 @@ tr46@^2.0.2:
dependencies: dependencies:
punycode "^2.1.1" punycode "^2.1.1"
ts-jest@^26.4.0: ts-jest@^26.4.1:
version "26.4.0" version "26.4.1"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.0.tgz#903c7827f3d3bc33efc2f91be294b164400c32e3" resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.1.tgz#08ec0d3fc2c3a39e4a46eae5610b69fafa6babd0"
integrity sha512-ofBzoCqf6Nv/PoWb/ByV3VNKy2KJSikamOBxvR3E6eVdIw10GwAXoyvMWXXjZJK2s6S27ZE8fI+JBTnGaovl6Q== integrity sha512-F4aFq01aS6mnAAa0DljNmKr/Kk9y4HVZ1m6/rtJ0ED56cuxINGq3Q9eVAh+z5vcYKe5qnTMvv90vE8vUMFxomg==
dependencies: dependencies:
"@types/jest" "26.x" "@types/jest" "26.x"
bs-logger "0.x" bs-logger "0.x"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
set -e set -e
git checkout main #git checkout main
# Creating the new tag # Creating the new tag
new_tag="$1" 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 # Setting the version on the front end
cd ../../ cd ../../
@ -17,12 +17,16 @@ git add "ansible/VERSION"
cd docker/prod || exit 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/" ../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 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 ../prod/docker-compose.yml
git add ../../ansible/templates/docker-compose.yml
git add ../travis/docker_push.sh git add ../travis/docker_push.sh
# The commit # The commit

View file

@ -8,15 +8,16 @@
- [Administration](administration.md) - [Administration](administration.md)
- [Install with Docker](administration_install_docker.md) - [Install with Docker](administration_install_docker.md)
- [Install with Ansible](administration_install_ansible.md) - [Install with Ansible](administration_install_ansible.md)
- [Install with Kubernetes](administration_install_kubernetes.md)
- [Configuration](administration_configuration.md) - [Configuration](administration_configuration.md)
- [Backup and Restore](administration_backup_and_restore.md) - [Backup and Restore](administration_backup_and_restore.md)
- [Federation](administration_federation.md)
- [Contributing](contributing.md) - [Contributing](contributing.md)
- [Docker Development](contributing_docker_development.md) - [Docker Development](contributing_docker_development.md)
- [Local Development](contributing_local_development.md) - [Local Development](contributing_local_development.md)
- [Tests](contributing_tests.md) - [Tests](contributing_tests.md)
- [Federation Development](contributing_federation_development.md) - [Federation Development](contributing_federation_development.md)
- [Websocket/HTTP API](contributing_websocket_http_api.md) - [Websocket/HTTP API](contributing_websocket_http_api.md)
- [Federation Overview](contributing_federation_overview.md)
- [ActivityPub API Outline](contributing_apub_api_outline.md) - [ActivityPub API Outline](contributing_apub_api_outline.md)
- [Theming Guide](contributing_theming.md) - [Theming Guide](contributing_theming.md)
- [Lemmy Council](lemmy_council.md) - [Lemmy Council](lemmy_council.md)

View file

@ -2,7 +2,7 @@
- Open source, [AGPL License](/LICENSE). - Open source, [AGPL License](/LICENSE).
- Self hostable, easy to deploy. - Self hostable, easy to deploy.
- Comes with [Docker](#docker), [Ansible](#ansible), [Kubernetes](#kubernetes). - Comes with [Docker](#docker) and [Ansible](#ansible).
- Clean, mobile-friendly interface. - Clean, mobile-friendly interface.
- Only a minimum of a username and password is required to sign up! - Only a minimum of a username and password is required to sign up!
- User avatar support. - User avatar support.

View file

@ -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.

View file

@ -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.

View file

@ -25,15 +25,21 @@ Open up your `docker-compose.yml`, and make sure `LEMMY_EXTERNAL_HOST` for `lemm
- LEMMY_HTTPS=false - 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: 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` `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: 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 ```bash
wget https://raw.githubusercontent.com/LemmyNet/lemmy/main/ansible/templates/nginx.conf wget https://raw.githubusercontent.com/LemmyNet/lemmy/main/ansible/templates/nginx.conf
# Replace the {{ vars }} # 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 sudo mv nginx.conf /etc/nginx/sites-enabled/lemmy.conf
``` ```

View file

@ -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.

View file

@ -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) - [GitHub (for issues and pull requests)](https://github.com/LemmyNet/lemmy)
- [Gitea (only for pull requests)](https://yerbamate.dev/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 ## Translating

View file

@ -1,5 +1,7 @@
# Activitypub API outline # 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. - 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.
<!-- toc --> <!-- toc -->

View file

@ -11,8 +11,8 @@ git clone https://github.com/LemmyNet/lemmy
## Running ## Running
```bash ```bash
cd lemmy/docker/dev cd /docker/dev
sudo docker-compose up --no-deps --build ./docker_update.sh
``` ```
and go to http://localhost:1235. and go to http://localhost:1235.

View file

@ -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.

View file

@ -36,6 +36,9 @@ cargo build
### Get the front end source code ### Get the front end source code
``` ```
git clone https://github.com/LemmyNet/lemmy-ui.git git clone https://github.com/LemmyNet/lemmy-ui.git
# get the translations
git submodule init
git submodule update --remote
``` ```
### Setup postgresql ### Setup postgresql
@ -78,7 +81,7 @@ yarn
yarn dev 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 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 iframely respectively). If you want to test those, you should use the

View file

@ -921,6 +921,7 @@ Search types are `All, Comments, Posts, Communities, Users, Url`
q: String, q: String,
type_: String, type_: String,
community_id: Option<i32>, community_id: Option<i32>,
community_name: Option<String>,
sort: String, sort: String,
page: Option<i64>, page: Option<i64>,
limit: Option<i64>, limit: Option<i64>,

View file

@ -357,6 +357,7 @@ impl Perform for Search {
let limit = data.limit; let limit = data.limit;
let sort = SortType::from_str(&data.sort)?; let sort = SortType::from_str(&data.sort)?;
let community_id = data.community_id; let community_id = data.community_id;
let community_name = data.community_name.to_owned();
match type_ { match type_ {
SearchType::Posts => { SearchType::Posts => {
posts = blocking(context.pool(), move |conn| { posts = blocking(context.pool(), move |conn| {
@ -364,6 +365,7 @@ impl Perform for Search {
.sort(&sort) .sort(&sort)
.show_nsfw(true) .show_nsfw(true)
.for_community_id(community_id) .for_community_id(community_id)
.for_community_name(community_name)
.search_term(q) .search_term(q)
.my_user_id(user_id) .my_user_id(user_id)
.page(page) .page(page)
@ -412,6 +414,7 @@ impl Perform for Search {
.sort(&sort) .sort(&sort)
.show_nsfw(true) .show_nsfw(true)
.for_community_id(community_id) .for_community_id(community_id)
.for_community_name(community_name)
.search_term(q) .search_term(q)
.my_user_id(user_id) .my_user_id(user_id)
.page(page) .page(page)
@ -466,6 +469,7 @@ impl Perform for Search {
.sort(&sort) .sort(&sort)
.show_nsfw(true) .show_nsfw(true)
.for_community_id(community_id) .for_community_id(community_id)
.for_community_name(community_name)
.url_search(q) .url_search(q)
.page(page) .page(page)
.limit(limit) .limit(limit)

View file

@ -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 // Make sure passwords match
if data.password != data.password_verify { if data.password != data.password_verify {
return Err(APIError::err("passwords_dont_match").into()); return Err(APIError::err("passwords_dont_match").into());
@ -172,7 +177,7 @@ impl Perform for Register {
admin: data.admin, admin: data.admin,
banned: false, banned: false,
show_nsfw: data.show_nsfw, show_nsfw: data.show_nsfw,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Active as i16, default_sort_type: SortType::Active as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -36,6 +36,7 @@ use activitystreams::{
}; };
use actix_web::{body::Body, web, web::Path, HttpResponse}; use actix_web::{body::Body, web, web::Path, HttpResponse};
use anyhow::Context; use anyhow::Context;
use diesel::result::Error::NotFound;
use itertools::Itertools; use itertools::Itertools;
use lemmy_db::{ use lemmy_db::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
@ -69,6 +70,9 @@ pub async fn get_apub_comment(
) -> Result<HttpResponse<Body>, LemmyError> { ) -> Result<HttpResponse<Body>, LemmyError> {
let id = info.comment_id.parse::<i32>()?; let id = info.comment_id.parse::<i32>()?;
let comment = blocking(context.pool(), move |conn| Comment::read(conn, id)).await??; let comment = blocking(context.pool(), move |conn| Comment::read(conn, id)).await??;
if !comment.local {
return Err(NotFound.into());
}
if !comment.deleted { if !comment.deleted {
Ok(create_apub_response( Ok(create_apub_response(

View file

@ -57,6 +57,10 @@ pub async fn community_inbox(
.into(), .into(),
); );
} }
debug!(
"Community {} received activity {:?}",
&community.name, &activity
);
let user_uri = activity let user_uri = activity
.actor()? .actor()?
.as_single_xsd_any_uri() .as_single_xsd_any_uri()

View file

@ -32,6 +32,7 @@ use activitystreams::{
use activitystreams_ext::Ext1; use activitystreams_ext::Ext1;
use actix_web::{body::Body, web, HttpResponse}; use actix_web::{body::Body, web, HttpResponse};
use anyhow::Context; use anyhow::Context;
use diesel::result::Error::NotFound;
use lemmy_db::{ use lemmy_db::{
community::Community, community::Community,
post::{Post, PostForm}, post::{Post, PostForm},
@ -62,6 +63,9 @@ pub async fn get_apub_post(
) -> Result<HttpResponse<Body>, LemmyError> { ) -> Result<HttpResponse<Body>, LemmyError> {
let id = info.post_id.parse::<i32>()?; let id = info.post_id.parse::<i32>()?;
let post = blocking(context.pool(), move |conn| Post::read(conn, id)).await??; let post = blocking(context.pool(), move |conn| Post::read(conn, id)).await??;
if !post.local {
return Err(NotFound.into());
}
if !post.deleted { if !post.deleted {
Ok(create_apub_response(&post.to_apub(context.pool()).await?)) Ok(create_apub_response(&post.to_apub(context.pool()).await?))

View file

@ -109,7 +109,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -284,7 +284,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -523,7 +523,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -87,6 +87,7 @@ impl Community {
pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Self, Error> { pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Self, Error> {
use crate::schema::community::dsl::*; use crate::schema::community::dsl::*;
community community
.filter(local)
.filter(name.eq(community_name)) .filter(name.eq(community_name))
.first::<Self>(conn) .first::<Self>(conn)
} }
@ -329,7 +330,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -420,7 +420,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),
@ -449,7 +449,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -104,7 +104,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -353,7 +353,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -273,12 +273,10 @@ impl<'a> PostQueryBuilder<'a> {
if let Some(for_community_id) = self.for_community_id { if let Some(for_community_id) = self.for_community_id {
query = query.filter(community_id.eq(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 { if let Some(for_community_name) = self.for_community_name {
query = query.filter(community_name.eq(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 { if let Some(url_search) = self.url_search {
@ -292,6 +290,8 @@ impl<'a> PostQueryBuilder<'a> {
.or_filter(body.ilike(searcher)); .or_filter(body.ilike(searcher));
} }
query = query.then_order_by(stickied.desc());
query = match self.sort { query = match self.sort {
SortType::Active => query SortType::Active => query
.then_order_by(hot_rank_active.desc()) .then_order_by(hot_rank_active.desc())
@ -418,7 +418,7 @@ mod tests {
admin: false, admin: false,
banned: false, banned: false,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -161,7 +161,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),
@ -190,7 +190,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -144,11 +144,17 @@ impl User_ {
} }
pub fn find_by_username(conn: &PgConnection, username: &str) -> Result<User_, Error> { pub fn find_by_username(conn: &PgConnection, username: &str) -> Result<User_, Error> {
user_.filter(name.ilike(username)).first::<User_>(conn) user_
.filter(local)
.filter(name.ilike(username))
.first::<User_>(conn)
} }
pub fn find_by_email(conn: &PgConnection, from_email: &str) -> Result<User_, Error> { pub fn find_by_email(conn: &PgConnection, from_email: &str) -> Result<User_, Error> {
user_.filter(email.eq(from_email)).first::<User_>(conn) user_
.filter(local)
.filter(email.eq(from_email))
.first::<User_>(conn)
} }
pub fn get_profile_url(&self, hostname: &str) -> String { pub fn get_profile_url(&self, hostname: &str) -> String {
@ -191,7 +197,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),
@ -221,7 +227,7 @@ mod tests {
published: inserted_user.published, published: inserted_user.published,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -100,7 +100,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),
@ -129,7 +129,7 @@ mod tests {
published: None, published: None,
updated: None, updated: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),

View file

@ -23,6 +23,7 @@ pub struct Search {
pub q: String, pub q: String,
pub type_: String, pub type_: String,
pub community_id: Option<i32>, pub community_id: Option<i32>,
pub community_name: Option<String>,
pub sort: String, pub sort: String,
pub page: Option<i64>, pub page: Option<i64>,
pub limit: Option<i64>, pub limit: Option<i64>,

View file

@ -88,7 +88,7 @@ fn create_user(conn: &PgConnection, name: &str) -> User_ {
updated: None, updated: None,
published: None, published: None,
show_nsfw: false, show_nsfw: false,
theme: "darkly".into(), theme: "browser".into(),
default_sort_type: SortType::Hot as i16, default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16, default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(), lang: "browser".into(),