From 2f63fdbde09d57ebbf2e891fe009d35f60847ac6 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 31 Mar 2021 06:54:46 -0400 Subject: [PATCH 01/14] Adding a setting to show / hide scores. Fixes #1503 --- crates/api/src/local_user.rs | 1 + crates/api_common/src/person.rs | 3 ++- crates/api_crud/src/user/create.rs | 1 + crates/db_queries/src/source/local_user.rs | 2 ++ crates/db_schema/src/schema.rs | 1 + crates/db_schema/src/source/local_user.rs | 3 +++ migrations/2021-03-31-103917_add_show_score_setting/down.sql | 1 + migrations/2021-03-31-103917_add_show_score_setting/up.sql | 1 + 8 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 migrations/2021-03-31-103917_add_show_score_setting/down.sql create mode 100644 migrations/2021-03-31-103917_add_show_score_setting/up.sql diff --git a/crates/api/src/local_user.rs b/crates/api/src/local_user.rs index 656ddf971..c28d8c725 100644 --- a/crates/api/src/local_user.rs +++ b/crates/api/src/local_user.rs @@ -267,6 +267,7 @@ impl Perform for SaveUserSettings { email, password_encrypted, show_nsfw: data.show_nsfw, + show_scores: data.show_scores, theme: data.theme.to_owned(), default_sort_type, default_listing_type, diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 7767da460..c4f8adbf9 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -47,6 +47,8 @@ pub struct CaptchaResponse { #[derive(Deserialize)] pub struct SaveUserSettings { pub show_nsfw: Option, + pub show_scores: Option, + pub show_avatars: Option, pub theme: Option, pub default_sort_type: Option, pub default_listing_type: Option, @@ -60,7 +62,6 @@ pub struct SaveUserSettings { pub new_password: Option, pub new_password_verify: Option, pub old_password: Option, - pub show_avatars: Option, pub send_notifications_to_email: Option, pub auth: String, } diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index 63a6474d6..c61c1e79a 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -133,6 +133,7 @@ impl PerformCrud for Register { default_listing_type: Some(ListingType::Subscribed as i16), lang: Some("browser".into()), show_avatars: Some(true), + show_scores: Some(true), send_notifications_to_email: Some(false), }; diff --git a/crates/db_queries/src/source/local_user.rs b/crates/db_queries/src/source/local_user.rs index 18720ceba..d1fad2e85 100644 --- a/crates/db_queries/src/source/local_user.rs +++ b/crates/db_queries/src/source/local_user.rs @@ -24,6 +24,7 @@ mod safe_settings_type { show_avatars, send_notifications_to_email, validator_time, + show_scores, ); impl ToSafeSettings for LocalUser { @@ -43,6 +44,7 @@ mod safe_settings_type { show_avatars, send_notifications_to_email, validator_time, + show_scores, ) } } diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 5bc55f529..a99908ad3 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -154,6 +154,7 @@ table! { show_avatars -> Bool, send_notifications_to_email -> Bool, validator_time -> Timestamp, + show_scores -> Bool, } } diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index 6f28a8fbc..0a7181fdb 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -16,6 +16,7 @@ pub struct LocalUser { pub show_avatars: bool, pub send_notifications_to_email: bool, pub validator_time: chrono::NaiveDateTime, + pub show_scores: bool, } // TODO redo these, check table defaults @@ -32,6 +33,7 @@ pub struct LocalUserForm { pub lang: Option, pub show_avatars: Option, pub send_notifications_to_email: Option, + pub show_scores: Option, } /// A local user view that removes password encrypted @@ -49,4 +51,5 @@ pub struct LocalUserSettings { pub show_avatars: bool, pub send_notifications_to_email: bool, pub validator_time: chrono::NaiveDateTime, + pub show_scores: bool, } diff --git a/migrations/2021-03-31-103917_add_show_score_setting/down.sql b/migrations/2021-03-31-103917_add_show_score_setting/down.sql new file mode 100644 index 000000000..9d35b5638 --- /dev/null +++ b/migrations/2021-03-31-103917_add_show_score_setting/down.sql @@ -0,0 +1 @@ +alter table local_user drop column show_scores; diff --git a/migrations/2021-03-31-103917_add_show_score_setting/up.sql b/migrations/2021-03-31-103917_add_show_score_setting/up.sql new file mode 100644 index 000000000..7960886a3 --- /dev/null +++ b/migrations/2021-03-31-103917_add_show_score_setting/up.sql @@ -0,0 +1 @@ +alter table local_user add column show_scores boolean default true not null; From fac024b90c75580a2b1de4c7e36bc73d9d18b20a Mon Sep 17 00:00:00 2001 From: mickie <47344817+mugcake@users.noreply.github.com> Date: Wed, 31 Mar 2021 13:02:27 -0600 Subject: [PATCH 02/14] Translated README.md to Spanish (#1525) * Add menu bar for language selection * Create README.es.md * Update README.es.md * fix minor issues * Update README.md * Update and rename README.es.md to readmes/README.es.md * Update features section. * Update README.md * Update README.es.md --- README.md | 5 ++ readmes/README.es.md | 168 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 readmes/README.es.md diff --git a/README.md b/README.md index 1032ce408..4b70e70f9 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,11 @@ [![Awesome Humane Tech](https://raw.githubusercontent.com/humanetech-community/awesome-humane-tech/main/humane-tech-badge.svg?sanitize=true)](https://github.com/humanetech-community/awesome-humane-tech) +

+ English | + Español +

+

diff --git a/readmes/README.es.md b/readmes/README.es.md new file mode 100644 index 000000000..7b6371470 --- /dev/null +++ b/readmes/README.es.md @@ -0,0 +1,168 @@ +

+ +![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/LemmyNet/lemmy.svg) +[![Build Status](https://cloud.drone.io/api/badges/LemmyNet/lemmy/status.svg)](https://cloud.drone.io/LemmyNet/lemmy/) +[![GitHub issues](https://img.shields.io/github/issues-raw/LemmyNet/lemmy.svg)](https://github.com/LemmyNet/lemmy/issues) +[![Docker Pulls](https://img.shields.io/docker/pulls/dessalines/lemmy.svg)](https://cloud.docker.com/repository/docker/dessalines/lemmy/) +[![Translation status](http://weblate.yerbamate.ml/widgets/lemmy/-/lemmy/svg-badge.svg)](http://weblate.yerbamate.ml/engage/lemmy/) +[![License](https://img.shields.io/github/license/LemmyNet/lemmy.svg)](LICENSE) +![GitHub stars](https://img.shields.io/github/stars/LemmyNet/lemmy?style=social) +[![Awesome Humane Tech](https://raw.githubusercontent.com/humanetech-community/awesome-humane-tech/main/humane-tech-badge.svg?sanitize=true)](https://github.com/humanetech-community/awesome-humane-tech) +
+ +

+ English | + Español +

+ +

+ + + +

Lemmy

+

+ Un agregador de enlaces / alternativa a Menéame - Reddit para el fediverso. +
+
+ Unirse a Lemmy + · + Documentación + · + Reportar Errores (bugs) + · + Solicitar Características + · + Lanzamientos + · + Código de Conducta +

+

+ +## Sobre El Proyecto + +Escritorio|Móvil +---|--- +![desktop](https://raw.githubusercontent.com/LemmyNet/joinlemmy-site/main/src/assets/images/main_img.webp)|![mobile](https://raw.githubusercontent.com/LemmyNet/joinlemmy-site/main/src/assets/images/mobile_pic.webp) + +[Lemmy](https://github.com/LemmyNet/lemmy) es similar a sitios como [Menéame](https://www.meneame.net/), [Reddit](https://reddit.com), [Lobste.rs](https://lobste.rs), [Raddle](https://raddle.me), o [Hacker News](https://news.ycombinator.com/): te subscribes a los foros que te interesan, publicas enlaces y debates, luego votas y comentas en ellos. Entre bastidores, es muy diferente; cualquiera puede gestionar fácilmente un servidor, y todos estos servidores son federados (piensa en el correo electrónico), y conectados al mismo universo, llamado [Fediverso](https://es.wikipedia.org/wiki/Fediverso). + +Para un agregador de enlaces, esto significa que un usuario registrado en un servidor puede suscribirse a los foros de otro servidor, y puede mantener discusiones con usuarios registrados en otros lugares. + +El objetivo general es crear una alternativa a reddit y otros agregadores de enlaces, fácilmente auto-hospedada, descentralizada, fuera de su control e intromisión corporativa. + +Cada servidor lemmy puede establecer su propia política de moderación; nombrando a los administradores del sitio y a los moderadores de la comunidad para mantener alejados a los trolls, y fomentar un entorno saludable y no tóxico en el que puedan sentirse cómodos contribuyendo. + +*Nota: Las APIs WebSocket y HTTP actualmente son inestables* + +### ¿Por qué se llama Lemmy? + +- Cantante principal de [Motörhead](https://invidio.us/watch?v=pWB5JZRGl0U). +- El [videojuego de la vieja escuela](). +- El [Koopa de Super Mario](https://www.mariowiki.com/Lemmy_Koopa). +- Los [roedores peludos](http://sunchild.fpwc.org/lemming-the-little-giant-of-the-north/). + +### Creado Con + +- [Rust](https://www.rust-lang.org) +- [Actix](https://actix.rs/) +- [Diesel](http://diesel.rs/) +- [Inferno](https://infernojs.org) +- [Typescript](https://www.typescriptlang.org/) + +# Características + +- Código abierto, [Licencia AGPL](/LICENSE). +- Auto-hospedado, fácil de desplegar (deploy). + - Viene con [Docker](#docker) y [Ansible](#ansible). +- Interfaz limpia y fácil de usar. Apta para dispositivos móviles. + - Sólo se requiere como mínimo un nombre de usuario y una contraseñar para inscribirse! + - Soporte de avatar de usuario. + - Hilos de comentarios actualizados en directo. + - Puntuaciones completas de los votos `(+/-)` como en el antiguo reddit. + - Temas, incluidos los claros, los oscuros, y los solarizados. + - Emojis con soporte de autocompletado. Empieza tecleando `:` + - *Ejemplo* `miau :cat:` => `miau 🐈` + - Etiquetado de Usuarios con `@`, etiquetado de Comunidades con `!`. + - *Ejemplo* `@miguel@lemmy.ml me invitó a la comunidad !gaming@lemmy.ml` + - Carga de imágenes integrada tanto en las publicaciones como en los comentarios. + - Una publicación puede consistir en un título y cualquier combinación de texto propio, una URL o nada más. + - Notificaciones, sobre las respuestas a los comentarios y cuando te etiquetan. + - Las notificaciones se pueden enviar por correo electrónico. + - Soporte para mensajes privados. + - Soporte de i18n / internacionalización. + - Fuentes RSS / Atom para Todo `All`, Suscrito `Subscribed`, Bandeja de entrada `inbox`, Usuario `User`, y Comunidad `Community`. +- Soporte para la publicación cruzada (cross-posting). + - **búsqueda de publicaciones similares** al crear una nueva. Ideal para comunidades de preguntas y respuestas. +- Capacidades de moderación. + - Registros públicos de moderación. + - Puedes pegar las publicaciones a la parte superior de las comunidades. + - Tanto los administradores del sitio, como los moderadores de la comunidad, pueden nombrar a otros moderadores. + - Puedes bloquear, eliminar y restaurar publicaciones y comentarios. + - Puedes banear y desbanear usuarios de las comunidades y del sitio. + - Puedes transferir el sitio y las comunidades a otros. +- Puedes borrar completamente tus datos, reemplazando todas las publicaciones y comentarios. +- Soporte para publicaciones y comunidades NSFW. +- Alto rendimiento. + - El servidor está escrito en rust. + - El front end está comprimido (gzipped) en `~80kB`. + - El front end funciona sin javascript (sólo lectura). + - Soporta arm64 / Raspberry Pi. + +## Instalación + +- [Docker](https://join.lemmy.ml/docs/es/administration/install_docker.html) +- [Ansible](https://join.lemmy.ml/docs/es/administration/install_ansible.html) + +## Proyectos de Lemmy + +### Aplicaciones + +- [lemmy-ui - La aplicación web oficial para lemmy](https://github.com/LemmyNet/lemmy-ui) +- [Lemmur - Un cliente móvil para Lemmy (Android, Linux, Windows)](https://github.com/krawieck/lemmur) +- [Remmel - Una aplicación IOS nativa](https://github.com/uuttff8/Lemmy-iOS) + +### Librerías + +- [lemmy-js-client](https://github.com/LemmyNet/lemmy-js-client) +- [Kotlin API ( en desarrollo )](https://github.com/eiknat/lemmy-client) +- [Dart API client ( en desarrollo )](https://github.com/krawieck/lemmy_api_client) + +## Apoyo / Donación + +Lemmy es un software libre y de código abierto, lo que significa que no hay publicidad, monetización o capital de riesgo, nunca. Tus donaciones apoyan directamente el desarrollo a tiempo completo del proyecto. + +- [Apoya en Liberapay](https://liberapay.com/Lemmy). +- [Apoya en Patreon](https://www.patreon.com/dessalines). +- [Apoya en OpenCollective](https://opencollective.com/lemmy). +- [Lista de patrocinadores](https://join.lemmy.ml/sponsors). + +### Crypto + +- bitcoin: `1Hefs7miXS5ff5Ck5xvmjKjXf5242KzRtK` +- ethereum: `0x400c96c96acbC6E7B3B43B1dc1BB446540a88A01` +- monero: `41taVyY6e1xApqKyMVDRVxJ76sPkfZhALLTjRvVKpaAh2pBd4wv9RgYj1tSPrx8wc6iE1uWUfjtQdTmTy2FGMeChGVKPQuV` + +## Contribuir + +- [Instrucciones para contribuir](https://join.lemmy.ml/docs/es/contributing/contributing.html) +- [Desarrollo por Docker](https://join.lemmy.ml/docs/es/contributing/docker_development.html) +- [Desarrollo Local](https://join.lemmy.ml/docs/es/contributing/local_development.html) + +### Traducciones + +Si quieres ayudar con la traducción, echa un vistazo a [Weblate](https://weblate.yerbamate.ml/projects/lemmy/). También puedes ayudar [traduciendo la documentación](https://github.com/LemmyNet/lemmy-docs#adding-a-new-language). + +## Contacto + +- [Mastodon](https://mastodon.social/@LemmyDev) +- [Matrix](https://matrix.to/#/#lemmy:matrix.org) + +## Repositorios del código + +- [GitHub](https://github.com/LemmyNet/lemmy) +- [Gitea](https://yerbamate.ml/LemmyNet/lemmy) +- [Codeberg](https://codeberg.org/LemmyNet/lemmy) + +## Creditos + +Logo hecho por Andy Cuccaro (@andycuccaro) bajo la licencia CC-BY-SA 4.0. From 1ba570092e0043b7516cccbbb5c27451eb1f0e6a Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 1 Apr 2021 13:30:24 -0400 Subject: [PATCH 03/14] Adding more rust captcha features. Fixes #1248 --- crates/api/src/lib.rs | 60 +++++------------------------- crates/api/src/local_user.rs | 8 ++-- crates/api_common/src/person.rs | 4 +- docker/dev/Dockerfile | 3 -- docker/dev/volume_mount.dockerfile | 4 +- docker/prod/Dockerfile | 3 -- docker/prod/Dockerfile.arm | 4 +- 7 files changed, 18 insertions(+), 68 deletions(-) diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 5dc678be6..c9de749ef 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -1,9 +1,9 @@ use actix_web::{web, web::Data}; +use captcha::Captcha; use lemmy_api_common::{comment::*, community::*, person::*, post::*, site::*, websocket::*}; use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation}; use serde::Deserialize; -use std::{env, process::Command}; mod comment; mod comment_report; @@ -158,60 +158,23 @@ where serialize_websocket_message(&op, &res) } -pub(crate) fn captcha_espeak_wav_base64(captcha: &str) -> Result { - let mut built_text = String::new(); +/// Converts the captcha to a base64 encoded wav audio file +pub(crate) fn captcha_as_wav_base64(captcha: &Captcha) -> String { + let letters = captcha.as_wav(); - // Building proper speech text for espeak - for mut c in captcha.chars() { - let new_str = if c.is_alphabetic() { - if c.is_lowercase() { - c.make_ascii_uppercase(); - format!("lower case {} ... ", c) - } else { - c.make_ascii_uppercase(); - format!("capital {} ... ", c) - } - } else { - format!("{} ...", c) - }; + let mut concat_letters: Vec = Vec::new(); - built_text.push_str(&new_str); + for letter in letters { + let bytes = letter.unwrap_or_default(); + concat_letters.extend(bytes); } - espeak_wav_base64(&built_text) -} - -pub(crate) fn espeak_wav_base64(text: &str) -> Result { - // Make a temp file path - let uuid = uuid::Uuid::new_v4().to_string(); - let file_path = format!( - "{}/lemmy_espeak_{}.wav", - env::temp_dir().to_string_lossy(), - &uuid - ); - - // Write the wav file - Command::new("espeak") - .arg("-w") - .arg(&file_path) - .arg(text) - .status()?; - - // Read the wav file bytes - let bytes = std::fs::read(&file_path)?; - - // Delete the file - std::fs::remove_file(file_path)?; - // Convert to base64 - let base64 = base64::encode(bytes); - - Ok(base64) + base64::encode(concat_letters) } #[cfg(test)] mod tests { - use crate::captcha_espeak_wav_base64; use lemmy_api_common::check_validator_time; use lemmy_db_queries::{establish_unpooled_connection, source::local_user::LocalUser_, Crud}; use lemmy_db_schema::source::{ @@ -253,9 +216,4 @@ mod tests { let num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); assert_eq!(1, num_deleted); } - - #[test] - fn test_espeak() { - assert!(captcha_espeak_wav_base64("WxRt2l").is_ok()) - } } diff --git a/crates/api/src/local_user.rs b/crates/api/src/local_user.rs index 656ddf971..831e38a17 100644 --- a/crates/api/src/local_user.rs +++ b/crates/api/src/local_user.rs @@ -1,4 +1,4 @@ -use crate::{captcha_espeak_wav_base64, Perform}; +use crate::{captcha_as_wav_base64, Perform}; use actix_web::web::Data; use anyhow::Context; use bcrypt::verify; @@ -135,13 +135,11 @@ impl Perform for GetCaptcha { let answer = captcha.chars_as_string(); - let png_byte_array = captcha.as_png().expect("failed to generate captcha"); - - let png = base64::encode(png_byte_array); + let png = captcha.as_base64().expect("failed to generate captcha"); let uuid = uuid::Uuid::new_v4().to_string(); - let wav = captcha_espeak_wav_base64(&answer).ok(); + let wav = captcha_as_wav_base64(&captcha); let captcha_item = CaptchaItem { answer, diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 7767da460..7b732412c 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -39,8 +39,8 @@ pub struct GetCaptchaResponse { #[derive(Serialize)] pub struct CaptchaResponse { - pub png: String, // A Base64 encoded png - pub wav: Option, // A Base64 encoded wav audio + pub png: String, // A Base64 encoded png + pub wav: String, // A Base64 encoded wav audio pub uuid: String, } diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 954c85c84..5d2acec7f 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -49,9 +49,6 @@ FROM alpine:3.12 as lemmy # Install libpq for postgres RUN apk add libpq -# Install Espeak for captchas -RUN apk add espeak - RUN addgroup -g 1000 lemmy RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy diff --git a/docker/dev/volume_mount.dockerfile b/docker/dev/volume_mount.dockerfile index 0cb036247..d848e0ea6 100644 --- a/docker/dev/volume_mount.dockerfile +++ b/docker/dev/volume_mount.dockerfile @@ -19,9 +19,9 @@ RUN --mount=type=cache,target=/app/target \ FROM ubuntu:20.10 -# Install libpq for postgres and espeak +# Install libpq for postgres RUN apt-get update -y -RUN apt-get install -y libpq-dev espeak +RUN apt-get install -y libpq-dev # Copy resources COPY config/defaults.hjson /config/defaults.hjson diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 2ad601aec..88a05fb26 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -49,9 +49,6 @@ FROM alpine:3.12 as lemmy # Install libpq for postgres RUN apk add libpq -# Install Espeak for captchas -RUN apk add espeak - RUN addgroup -g 1000 lemmy RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy diff --git a/docker/prod/Dockerfile.arm b/docker/prod/Dockerfile.arm index 61d1f86c9..b3eacb4f9 100644 --- a/docker/prod/Dockerfile.arm +++ b/docker/prod/Dockerfile.arm @@ -22,9 +22,9 @@ RUN cp ./target/release/lemmy_server /app/lemmy_server # The Debian runner FROM debian:buster-slim as lemmy -# Install libpq for postgres and espeak for captchas +# Install libpq for postgres RUN apt-get update \ - && apt-get -y install --no-install-recommends espeak postgresql-client libc6 libssl1.1 \ + && apt-get -y install --no-install-recommends postgresql-client libc6 libssl1.1 \ && rm -rf /var/lib/apt/lists/* RUN addgroup --gid 1000 lemmy From bf7558830f6bd711d259f6641c52e8395bbab437 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 1 Apr 2021 13:57:45 -0400 Subject: [PATCH 04/14] Changing preferred to display name. Fixes #1211 --- api_tests/package.json | 2 +- api_tests/src/user.spec.ts | 4 ++-- api_tests/yarn.lock | 8 ++++---- crates/api/src/local_user.rs | 10 +++++----- crates/api_common/src/person.rs | 2 +- crates/apub/src/objects/person.rs | 9 +++++---- crates/db_queries/src/source/person.rs | 16 ++++++++-------- crates/db_schema/src/schema.rs | 6 +++--- crates/db_schema/src/source/person.rs | 14 +++++++------- crates/db_views/src/comment_view.rs | 2 +- crates/db_views/src/post_view.rs | 2 +- crates/utils/src/test.rs | 8 ++++---- crates/utils/src/utils.rs | 6 ++---- .../down.sql | 6 ++++++ .../up.sql | 6 ++++++ 15 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql create mode 100644 migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql diff --git a/api_tests/package.json b/api_tests/package.json index 7cb949594..1b0583c4f 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -16,7 +16,7 @@ "eslint": "^7.18.0", "eslint-plugin-jane": "^9.0.3", "jest": "^26.6.3", - "lemmy-js-client": "0.10.0-rc.13", + "lemmy-js-client": "0.11.0-rc.1", "node-fetch": "^2.6.1", "prettier": "^2.1.2", "ts-jest": "^26.4.4", diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index a10876cf5..5d10fd043 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -19,7 +19,7 @@ let apShortname: string; function assertUserFederation(userOne: PersonViewSafe, userTwo: PersonViewSafe) { expect(userOne.person.name).toBe(userTwo.person.name); - expect(userOne.person.preferred_username).toBe(userTwo.person.preferred_username); + expect(userOne.person.display_name).toBe(userTwo.person.display_name); expect(userOne.person.bio).toBe(userTwo.person.bio); expect(userOne.person.actor_id).toBe(userTwo.person.actor_id); expect(userOne.person.avatar).toBe(userTwo.person.avatar); @@ -49,7 +49,7 @@ test('Set some user settings, check that they are federated', async () => { lang: '', avatar, banner, - preferred_username: 'user321', + display_name: 'user321', show_avatars: false, send_notifications_to_email: false, bio, diff --git a/api_tests/yarn.lock b/api_tests/yarn.lock index 8f8abf873..f3b8e603f 100644 --- a/api_tests/yarn.lock +++ b/api_tests/yarn.lock @@ -3233,10 +3233,10 @@ language-tags@^1.0.5: dependencies: language-subtag-registry "~0.3.2" -lemmy-js-client@0.10.0-rc.13: - version "0.10.0-rc.13" - resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.10.0-rc.13.tgz#ea2e88857243374d7fbd49ee6b4bb94c34359d85" - integrity sha512-zodvYkwBYR7iP27ah6L/QPUphUUdq38kCH7QF2CUYBrsSAEkGmq2kdz+iusnQ1Ht7Ad80GtYycFprsZBveV5eQ== +lemmy-js-client@0.11.0-rc.1: + version "0.11.0-rc.1" + resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0-rc.1.tgz#0031676be9fc787157a21dd3f5095dd1ee9e6a57" + integrity sha512-dtpxe/hHTbYEv2WnfGkAieOB9jyKUVED+y4DosUp/FcaatjPcMTiKOvCdMNjlvvG/9GyclWEoyNitPEsvJwjmg== leven@^3.1.0: version "3.1.0" diff --git a/crates/api/src/local_user.rs b/crates/api/src/local_user.rs index 656ddf971..2fb4056f2 100644 --- a/crates/api/src/local_user.rs +++ b/crates/api/src/local_user.rs @@ -60,7 +60,7 @@ use lemmy_utils::{ email::send_email, location_info, settings::structs::Settings, - utils::{generate_random_string, is_valid_preferred_username, naive_from_unix}, + utils::{generate_random_string, is_valid_display_name, naive_from_unix}, ApiError, ConnectionId, LemmyError, @@ -174,7 +174,7 @@ impl Perform for SaveUserSettings { let banner = diesel_option_overwrite_to_url(&data.banner)?; let email = diesel_option_overwrite(&data.email); let bio = diesel_option_overwrite(&data.bio); - let preferred_username = diesel_option_overwrite(&data.preferred_username); + let display_name = diesel_option_overwrite(&data.display_name); let matrix_user_id = diesel_option_overwrite(&data.matrix_user_id); if let Some(Some(bio)) = &bio { @@ -183,8 +183,8 @@ impl Perform for SaveUserSettings { } } - if let Some(Some(preferred_username)) = &preferred_username { - if !is_valid_preferred_username(preferred_username.trim()) { + if let Some(Some(display_name)) = &display_name { + if !is_valid_display_name(display_name.trim()) { return Err(ApiError::err("invalid_username").into()); } } @@ -235,7 +235,7 @@ impl Perform for SaveUserSettings { avatar, banner, inbox_url: None, - preferred_username, + display_name, published: None, updated: Some(naive_now()), banned: None, diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 7767da460..d95fed6b5 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -53,7 +53,7 @@ pub struct SaveUserSettings { pub lang: Option, pub avatar: Option, pub banner: Option, - pub preferred_username: Option, + pub display_name: Option, pub email: Option, pub bio: Option, pub matrix_user_id: Option, diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index 25c785d84..3e468d5c8 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -64,7 +64,8 @@ impl ToApub for DbPerson { set_content_and_source(&mut person, bio)?; } - if let Some(i) = self.preferred_username.to_owned() { + // In apub, the "name" is a display name + if let Some(i) = self.display_name.to_owned() { person.set_name(i); } @@ -161,7 +162,7 @@ impl FromApubToForm for PersonForm { .preferred_username() .context(location_info!())? .to_string(); - let preferred_username: Option = person + let display_name: Option = person .name() .map(|n| n.one()) .flatten() @@ -176,12 +177,12 @@ impl FromApubToForm for PersonForm { .map(|s| s.to_owned().into()); check_slurs(&name)?; - check_slurs_opt(&preferred_username)?; + check_slurs_opt(&display_name)?; check_slurs_opt(&bio)?; Ok(PersonForm { name, - preferred_username: Some(preferred_username), + display_name: Some(display_name), banned: None, deleted: None, avatar: avatar.map(|o| o.map(|i| i.into())), diff --git a/crates/db_queries/src/source/person.rs b/crates/db_queries/src/source/person.rs index 35ed540c0..2d332bd01 100644 --- a/crates/db_queries/src/source/person.rs +++ b/crates/db_queries/src/source/person.rs @@ -15,7 +15,7 @@ mod safe_type { type Columns = ( id, name, - preferred_username, + display_name, avatar, banned, published, @@ -37,7 +37,7 @@ mod safe_type { ( id, name, - preferred_username, + display_name, avatar, banned, published, @@ -63,7 +63,7 @@ mod safe_type_alias_1 { type Columns = ( id, name, - preferred_username, + display_name, avatar, banned, published, @@ -85,7 +85,7 @@ mod safe_type_alias_1 { ( id, name, - preferred_username, + display_name, avatar, banned, published, @@ -111,7 +111,7 @@ mod safe_type_alias_2 { type Columns = ( id, name, - preferred_username, + display_name, avatar, banned, published, @@ -133,7 +133,7 @@ mod safe_type_alias_2 { ( id, name, - preferred_username, + display_name, avatar, banned, published, @@ -236,7 +236,7 @@ impl Person_ for Person { diesel::update(person.find(person_id)) .set(( - preferred_username.eq::>(None), + display_name.eq::>(None), bio.eq::>(None), matrix_user_id.eq::>(None), deleted.eq(true), @@ -264,7 +264,7 @@ mod tests { let expected_person = Person { id: inserted_person.id, name: "holly".into(), - preferred_username: None, + display_name: None, avatar: None, banner: None, banned: false, diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 5bc55f529..04b5322c4 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -270,7 +270,7 @@ table! { person (id) { id -> Int4, name -> Varchar, - preferred_username -> Nullable, + display_name -> Nullable, avatar -> Nullable, banned -> Bool, published -> Timestamp, @@ -470,7 +470,7 @@ table! { person_alias_1 (id) { id -> Int4, name -> Varchar, - preferred_username -> Nullable, + display_name -> Nullable, avatar -> Nullable, banned -> Bool, published -> Timestamp, @@ -494,7 +494,7 @@ table! { person_alias_2 (id) { id -> Int4, name -> Varchar, - preferred_username -> Nullable, + display_name -> Nullable, avatar -> Nullable, banned -> Bool, published -> Timestamp, diff --git a/crates/db_schema/src/source/person.rs b/crates/db_schema/src/source/person.rs index 2c0e7e8b7..be1ce268f 100644 --- a/crates/db_schema/src/source/person.rs +++ b/crates/db_schema/src/source/person.rs @@ -10,7 +10,7 @@ use serde::Serialize; pub struct Person { pub id: PersonId, pub name: String, - pub preferred_username: Option, + pub display_name: Option, pub avatar: Option, pub banned: bool, pub published: chrono::NaiveDateTime, @@ -35,7 +35,7 @@ pub struct Person { pub struct PersonSafe { pub id: PersonId, pub name: String, - pub preferred_username: Option, + pub display_name: Option, pub avatar: Option, pub banned: bool, pub published: chrono::NaiveDateTime, @@ -56,7 +56,7 @@ pub struct PersonSafe { pub struct PersonAlias1 { pub id: PersonId, pub name: String, - pub preferred_username: Option, + pub display_name: Option, pub avatar: Option, pub banned: bool, pub published: chrono::NaiveDateTime, @@ -80,7 +80,7 @@ pub struct PersonAlias1 { pub struct PersonSafeAlias1 { pub id: PersonId, pub name: String, - pub preferred_username: Option, + pub display_name: Option, pub avatar: Option, pub banned: bool, pub published: chrono::NaiveDateTime, @@ -101,7 +101,7 @@ pub struct PersonSafeAlias1 { pub struct PersonAlias2 { pub id: PersonId, pub name: String, - pub preferred_username: Option, + pub display_name: Option, pub avatar: Option, pub banned: bool, pub published: chrono::NaiveDateTime, @@ -125,7 +125,7 @@ pub struct PersonAlias2 { pub struct PersonSafeAlias2 { pub id: PersonId, pub name: String, - pub preferred_username: Option, + pub display_name: Option, pub avatar: Option, pub banned: bool, pub published: chrono::NaiveDateTime, @@ -145,7 +145,7 @@ pub struct PersonSafeAlias2 { #[table_name = "person"] pub struct PersonForm { pub name: String, - pub preferred_username: Option>, + pub display_name: Option>, pub avatar: Option>, pub banned: Option, pub published: Option, diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 6b13103c0..ff5b6debf 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -519,7 +519,7 @@ mod tests { creator: PersonSafe { id: inserted_person.id, name: "timmy".into(), - preferred_username: None, + display_name: None, published: inserted_person.published, avatar: None, actor_id: inserted_person.actor_id.to_owned(), diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index df67d3693..64f261aad 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -541,7 +541,7 @@ mod tests { creator: PersonSafe { id: inserted_person.id, name: person_name, - preferred_username: None, + display_name: None, published: inserted_person.published, avatar: None, actor_id: inserted_person.actor_id.to_owned(), diff --git a/crates/utils/src/test.rs b/crates/utils/src/test.rs index aaa59bfa7..04abd4b7d 100644 --- a/crates/utils/src/test.rs +++ b/crates/utils/src/test.rs @@ -1,7 +1,7 @@ use crate::utils::{ is_valid_community_name, + is_valid_display_name, is_valid_post_title, - is_valid_preferred_username, is_valid_username, remove_slurs, scrape_text_for_mentions, @@ -29,9 +29,9 @@ fn test_valid_register_username() { } #[test] -fn test_valid_preferred_username() { - assert!(is_valid_preferred_username("hello @there")); - assert!(!is_valid_preferred_username("@hello there")); +fn test_valid_display_name() { + assert!(is_valid_display_name("hello @there")); + assert!(!is_valid_display_name("@hello there")); } #[test] diff --git a/crates/utils/src/utils.rs b/crates/utils/src/utils.rs index c53d6c7c2..931565b6d 100644 --- a/crates/utils/src/utils.rs +++ b/crates/utils/src/utils.rs @@ -108,10 +108,8 @@ pub fn is_valid_username(name: &str) -> bool { } // Can't do a regex here, reverse lookarounds not supported -pub fn is_valid_preferred_username(preferred_username: &str) -> bool { - !preferred_username.starts_with('@') - && preferred_username.chars().count() >= 3 - && preferred_username.chars().count() <= 20 +pub fn is_valid_display_name(name: &str) -> bool { + !name.starts_with('@') && name.chars().count() >= 3 && name.chars().count() <= 20 } pub fn is_valid_community_name(name: &str) -> bool { diff --git a/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql b/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql new file mode 100644 index 000000000..844c02d38 --- /dev/null +++ b/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql @@ -0,0 +1,6 @@ +alter table person rename display_name to preferred_username; + +-- Regenerate the person_alias views +drop view person_alias_1, person_alias_2; +create view person_alias_1 as select * from person; +create view person_alias_2 as select * from person; diff --git a/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql b/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql new file mode 100644 index 000000000..f4b9729c1 --- /dev/null +++ b/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql @@ -0,0 +1,6 @@ +alter table person rename preferred_username to display_name; + +-- Regenerate the person_alias views +drop view person_alias_1, person_alias_2; +create view person_alias_1 as select * from person; +create view person_alias_2 as select * from person; From 799ab94af313f635dbe4547ea2f9a85c3124fd11 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 1 Apr 2021 14:09:53 -0400 Subject: [PATCH 05/14] Don't allow zero-space char in display name. Fixes #1317 --- crates/utils/src/test.rs | 6 ++++++ crates/utils/src/utils.rs | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/utils/src/test.rs b/crates/utils/src/test.rs index 04abd4b7d..754aa8c3a 100644 --- a/crates/utils/src/test.rs +++ b/crates/utils/src/test.rs @@ -32,6 +32,12 @@ fn test_valid_register_username() { fn test_valid_display_name() { assert!(is_valid_display_name("hello @there")); assert!(!is_valid_display_name("@hello there")); + + // Make sure zero-space with an @ doesn't work + assert!(!is_valid_display_name(&format!( + "{}@my name is", + '\u{200b}' + ))); } #[test] diff --git a/crates/utils/src/utils.rs b/crates/utils/src/utils.rs index 931565b6d..732ac2c8d 100644 --- a/crates/utils/src/utils.rs +++ b/crates/utils/src/utils.rs @@ -109,7 +109,10 @@ pub fn is_valid_username(name: &str) -> bool { // Can't do a regex here, reverse lookarounds not supported pub fn is_valid_display_name(name: &str) -> bool { - !name.starts_with('@') && name.chars().count() >= 3 && name.chars().count() <= 20 + !name.starts_with('@') + && !name.starts_with('\u{200b}') + && name.chars().count() >= 3 + && name.chars().count() <= 20 } pub fn is_valid_community_name(name: &str) -> bool { From b893085d1fc73b60468b35cfef0d5e007173ca49 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 1 Apr 2021 14:34:27 -0400 Subject: [PATCH 06/14] Adding users active monthly for community sort. Fixes #1527 --- crates/db_views_actor/src/community_view.rs | 1 + .../down.sql | 1 + .../up.sql | 2 ++ 3 files changed, 4 insertions(+) create mode 100644 migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql create mode 100644 migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index fe3a80bb7..87b9cbcf1 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views_actor/src/community_view.rs @@ -193,6 +193,7 @@ impl<'a> CommunityQueryBuilder<'a> { match self.sort { SortType::New => query = query.order_by(community::published.desc()), SortType::TopAll => query = query.order_by(community_aggregates::subscribers.desc()), + SortType::TopMonth => query = query.order_by(community_aggregates::users_active_month.desc()), // Covers all other sorts, including hot _ => { query = query diff --git a/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql b/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql new file mode 100644 index 000000000..9748bc17f --- /dev/null +++ b/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql @@ -0,0 +1 @@ +drop index idx_community_aggregates_users_active_month; diff --git a/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql b/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql new file mode 100644 index 000000000..4ae90e0ab --- /dev/null +++ b/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql @@ -0,0 +1,2 @@ +create index idx_community_aggregates_users_active_month on community_aggregates (users_active_month desc); + From ba517249e84933fe57c7a4d44d99e55e2722c108 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 5 Apr 2021 08:53:28 -0400 Subject: [PATCH 07/14] Version 0.10.0 --- ansible/VERSION | 2 +- crates/utils/src/version.rs | 2 +- docker/dev/docker-compose.yml | 2 +- docker/federation/docker-compose.yml | 10 +++++----- docker/prod/docker-compose.yml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ansible/VERSION b/ansible/VERSION index 7e310bae1..78bc1abd1 100644 --- a/ansible/VERSION +++ b/ansible/VERSION @@ -1 +1 @@ -0.9.9 +0.10.0 diff --git a/crates/utils/src/version.rs b/crates/utils/src/version.rs index 133ba6080..a50d0adf2 100644 --- a/crates/utils/src/version.rs +++ b/crates/utils/src/version.rs @@ -1 +1 @@ -pub const VERSION: &str = "0.10.0-rc.13"; +pub const VERSION: &str = "0.10.0"; diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index d16a9331c..af2516d2b 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -17,7 +17,7 @@ services: - iframely lemmy-ui: - image: dessalines/lemmy-ui:0.10.0-rc.13 + image: dessalines/lemmy-ui:0.10.0 ports: - "1235:1234" restart: always diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index d683f7764..233897248 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -29,7 +29,7 @@ services: - ./volumes/pictrs_alpha:/mnt lemmy-alpha-ui: - image: dessalines/lemmy-ui:0.10.0-rc.13 + image: dessalines/lemmy-ui:0.10.0 environment: - LEMMY_INTERNAL_HOST=lemmy-alpha:8541 - LEMMY_EXTERNAL_HOST=localhost:8541 @@ -58,7 +58,7 @@ services: - ./volumes/postgres_alpha:/var/lib/postgresql/data lemmy-beta-ui: - image: dessalines/lemmy-ui:0.10.0-rc.13 + image: dessalines/lemmy-ui:0.10.0 environment: - LEMMY_INTERNAL_HOST=lemmy-beta:8551 - LEMMY_EXTERNAL_HOST=localhost:8551 @@ -87,7 +87,7 @@ services: - ./volumes/postgres_beta:/var/lib/postgresql/data lemmy-gamma-ui: - image: dessalines/lemmy-ui:0.10.0-rc.13 + image: dessalines/lemmy-ui:0.10.0 environment: - LEMMY_INTERNAL_HOST=lemmy-gamma:8561 - LEMMY_EXTERNAL_HOST=localhost:8561 @@ -117,7 +117,7 @@ services: # An instance with only an allowlist for beta lemmy-delta-ui: - image: dessalines/lemmy-ui:0.10.0-rc.13 + image: dessalines/lemmy-ui:0.10.0 environment: - LEMMY_INTERNAL_HOST=lemmy-delta:8571 - LEMMY_EXTERNAL_HOST=localhost:8571 @@ -147,7 +147,7 @@ services: # An instance who has a blocklist, with lemmy-alpha blocked lemmy-epsilon-ui: - image: dessalines/lemmy-ui:0.10.0-rc.13 + image: dessalines/lemmy-ui:0.10.0 environment: - LEMMY_INTERNAL_HOST=lemmy-epsilon:8581 - LEMMY_EXTERNAL_HOST=localhost:8581 diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml index a508269a5..128d66155 100644 --- a/docker/prod/docker-compose.yml +++ b/docker/prod/docker-compose.yml @@ -12,7 +12,7 @@ services: restart: always lemmy: - image: dessalines/lemmy:0.9.9 + image: dessalines/lemmy:0.10.0 ports: - "127.0.0.1:8536:8536" restart: always From a617a6a6d6d4ca90f4b11649619c229d8b121ec3 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 5 Apr 2021 08:55:38 -0400 Subject: [PATCH 08/14] Update releases.md --- RELEASES.md | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index e64c7e92a..8f9e44e21 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,91 @@ +# Lemmy v0.10.0 Release (2021-04-05) + +## Changes + +Since our last release in February, we've had [~150](https://github.com/LemmyNet/lemmy/compare/0.9.9...main) commits to Lemmy. The biggest changes, as we'll outline below, are a split of Lemmy's user tables into federated and local tables, necessitating a `v3` of Lemmy's API, federated moderation, i18n support in join.lemmy.ml, and lots of back-end cleanup. + +### Lemmy Server + +#### General + +- Rewrote config implementation, finally allowing us to use newer Rust versions. +- Removed categories. +- Various refactors. + +#### API + +- A full list of the API changes can be seen on this diff of [lemmy-js-client: 0.9.9 -> 0.10.0](https://github.com/LemmyNet/lemmy-js-client/compare/0.9.9...0.10.0-rc.13) . +- Login invalidation on password change, thanks to @Mart-Bogdan + +#### Federation + +- It is now possible to add users from other instances as community mods. +- Federating Matrix ID. +- Many changes for better compatibility with ActivityPub standard. + +#### Database + +- Split the `user_` into `person` and `local_user` tables. +- Strictly typed commonly used ID columns, to prevent DB errors using `i32` as ids. +- Strictly typed URL fields, thanks to ajyoon. +- Created default DB forms, now used in all the unit tests. + +### Lemmy UI + +- Now using utf-8 emojis. +- Support for all the above changes to Lemmy. +- Typescript-safe i18n strings, thanks to @shilangyu. +- Added expandable post text (click on open book icon). +- Prettier cross-posting, which does smart quoting. +- Bugfixes for restoring scroll position on post page, custom site favicons, and autocomplete for login fields. + +### Lemmy Docs + +- Gazconroy built an [Async API spec for Lemmy](https://join.lemmy.ml/api/index.html), that now serves as our main API docs. + +### join.lemmy.ml + +- Rewrote in inferno isomorphic, added i18n support via [weblate](https://weblate.yerbamate.ml/projects/lemmy/joinlemmy/). +- Added a section on the support page thanking contributors. +- Changed some page urls / titles + +## Upgrade notes + +**Important**: there are multiple breaking changes: + +- Configuration via environment variables is not supported anymore, you must have all your config in the [lemmy.hjson](https://github.com/LemmyNet/lemmy/blob/main/ansible/templates/config.hjson) file ( except for `LEMMY_CONFIG_LOCATION` ). +- The config format for `allowed_instances` and `blocked_instances` has changed, and you need to adjust your config file manually: + - before: `allowed_instances: ds9.lemmy.ml,enterprise.lemmy.ml` + - now: `allowed_instances: ["ds9.lemmy.ml", "enterprise.lemmy.ml"]` , and only one of the `allowed_instances` or `blocked_instances` blocks can be set. +- The API has been upgraded from `v2` to `v3`, so all clients need to be updated: [lemmy-js-client: 0.9.9 -> 0.10.0](https://github.com/LemmyNet/lemmy-js-client/compare/0.9.9...0.10.0-rc.13) . + +If you'd like to make a DB backup before upgrading, follow [this guide](https://join.lemmy.ml/docs/en/administration/backup_and_restore.html). + +To upgrade your instance to `v0.10.0`, simply follow the instructions in the documentation: + +- [Upgrade with manual Docker installation](https://join.lemmy.ml/docs/en/administration/install_docker.html#updating) +- [Upgrade with Ansible installation](https://join.lemmy.ml/docs/en/administration/install_ansible.html) + + +## Compilation time + +|| v0.9.0 (Rust 1.47) | v0.10.0 (Rust 1.47) | v0.10.0 (Rust 1.51) | +|-| -------- | -------- | -------- | +|Clean | 140s | 146s | 119s | +| Incremental | 28s | 22s | 19s | + +Despite ongoing efforts to speed up compilation, it has actually gotten slower when comparing with the same Rust version. Only thanks to improvements in newer Rust versions has our build process gotten faster. This could be simply because we added more code, while Lemmy v0.9.0 had 22.4k lines of Rust, v0.10.0 has 23.8k (an increase of 6%). + +v0.9.0 build graph: +![](https://lemmy.ml/pictrs/image/GVBqFnrLqG.jpg) + +v0.10.0 build graph: +![](https://lemmy.ml/pictrs/image/NllzjVEyNK.jpg) + +We extracted the crates `lemmy_api_crud` and `lemmy_apub_receive` from `lemmy_api` and `lemmy_apub`, respectively, and renamed `lemmy_structs` to `lemmy_api_common`. In the second graph you can see how parts of the api and apub crates are now built nicely in parallel, speeding up builds on multi-core systems. + +On the other hand, some crates have gotten much slower to compile, in particular `lemmy_db_queries` (6.5s slower), `lemmy_apub` (6.5s slower if we include `lemmy_apub_receive`). And `lemmy_db_views` is quite slow, just as before. + # Lemmy v0.9.9 Release (2021-02-19) ## Changes From ebb980eaaf6f8b586cd9c1111ddd0cd96e731423 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 5 Apr 2021 10:20:40 -0400 Subject: [PATCH 09/14] Fix ansible deploy template. (#1544) * Fix ansible deploy template. * Add ansible comment. * Changing tls to true * Fixing comment line. --- ansible/templates/config.hjson | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ansible/templates/config.hjson b/ansible/templates/config.hjson index 55537ca50..51d25e77f 100644 --- a/ansible/templates/config.hjson +++ b/ansible/templates/config.hjson @@ -4,15 +4,22 @@ # settings related to the postgresql database database: { + database: lemmy + user: lemmy + host: postgres + port: 5432 + pool_size: 5 # password to connect to postgres password: "{{ postgres_password }}" - # host where postgres is running - host: "postgres" } # the domain name of your instance (eg "lemmy.ml") hostname: "{{ domain }}" + # the port where lemmy should listen for incoming requests + port: 8536 # json web token for authorization between server and client jwt_secret: "{{ jwt_password }}" + # whether tls is required for activitypub. only disable this for debugging, never for producion. + tls_enabled: true # email sending configuration email: { # hostname of the smtp server From f0c96c28bf2fa1576c55d42350e0041724a36f3c Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 5 Apr 2021 14:23:32 +0000 Subject: [PATCH 10/14] Crash if config fails to load (#1545) * Crash if config fails to load * fix previous commit --- crates/utils/src/settings/mod.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/crates/utils/src/settings/mod.rs b/crates/utils/src/settings/mod.rs index 0990a43de..d052fec6c 100644 --- a/crates/utils/src/settings/mod.rs +++ b/crates/utils/src/settings/mod.rs @@ -13,7 +13,6 @@ use crate::{ }; use anyhow::{anyhow, Context}; use deser_hjson::from_str; -use log::warn; use merge::Merge; use std::{env, fs, io::Error, net::IpAddr, sync::RwLock}; @@ -23,16 +22,8 @@ pub mod structs; static CONFIG_FILE: &str = "config/config.hjson"; lazy_static! { - static ref SETTINGS: RwLock = RwLock::new(match Settings::init() { - Ok(c) => c, - Err(e) => { - warn!( - "Couldn't load settings file, using default settings.\n{}", - e - ); - Settings::default() - } - }); + static ref SETTINGS: RwLock = + RwLock::new(Settings::init().expect("Failed to load settings file")); } impl Settings { From 458767e3a8279b1bb86c62758b70061d41833567 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 5 Apr 2021 10:29:14 -0400 Subject: [PATCH 11/14] Version 0.10.1 --- ansible/VERSION | 2 +- crates/utils/src/version.rs | 2 +- docker/dev/docker-compose.yml | 2 +- docker/federation/docker-compose.yml | 10 +++++----- docker/prod/docker-compose.yml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ansible/VERSION b/ansible/VERSION index 78bc1abd1..571215736 100644 --- a/ansible/VERSION +++ b/ansible/VERSION @@ -1 +1 @@ -0.10.0 +0.10.1 diff --git a/crates/utils/src/version.rs b/crates/utils/src/version.rs index a50d0adf2..b83fff578 100644 --- a/crates/utils/src/version.rs +++ b/crates/utils/src/version.rs @@ -1 +1 @@ -pub const VERSION: &str = "0.10.0"; +pub const VERSION: &str = "0.10.1"; diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index af2516d2b..071bdf29c 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -17,7 +17,7 @@ services: - iframely lemmy-ui: - image: dessalines/lemmy-ui:0.10.0 + image: dessalines/lemmy-ui:0.10.1 ports: - "1235:1234" restart: always diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 233897248..760fbe3b2 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -29,7 +29,7 @@ services: - ./volumes/pictrs_alpha:/mnt lemmy-alpha-ui: - image: dessalines/lemmy-ui:0.10.0 + image: dessalines/lemmy-ui:0.10.1 environment: - LEMMY_INTERNAL_HOST=lemmy-alpha:8541 - LEMMY_EXTERNAL_HOST=localhost:8541 @@ -58,7 +58,7 @@ services: - ./volumes/postgres_alpha:/var/lib/postgresql/data lemmy-beta-ui: - image: dessalines/lemmy-ui:0.10.0 + image: dessalines/lemmy-ui:0.10.1 environment: - LEMMY_INTERNAL_HOST=lemmy-beta:8551 - LEMMY_EXTERNAL_HOST=localhost:8551 @@ -87,7 +87,7 @@ services: - ./volumes/postgres_beta:/var/lib/postgresql/data lemmy-gamma-ui: - image: dessalines/lemmy-ui:0.10.0 + image: dessalines/lemmy-ui:0.10.1 environment: - LEMMY_INTERNAL_HOST=lemmy-gamma:8561 - LEMMY_EXTERNAL_HOST=localhost:8561 @@ -117,7 +117,7 @@ services: # An instance with only an allowlist for beta lemmy-delta-ui: - image: dessalines/lemmy-ui:0.10.0 + image: dessalines/lemmy-ui:0.10.1 environment: - LEMMY_INTERNAL_HOST=lemmy-delta:8571 - LEMMY_EXTERNAL_HOST=localhost:8571 @@ -147,7 +147,7 @@ services: # An instance who has a blocklist, with lemmy-alpha blocked lemmy-epsilon-ui: - image: dessalines/lemmy-ui:0.10.0 + image: dessalines/lemmy-ui:0.10.1 environment: - LEMMY_INTERNAL_HOST=lemmy-epsilon:8581 - LEMMY_EXTERNAL_HOST=localhost:8581 diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml index 128d66155..c1556dd9b 100644 --- a/docker/prod/docker-compose.yml +++ b/docker/prod/docker-compose.yml @@ -12,7 +12,7 @@ services: restart: always lemmy: - image: dessalines/lemmy:0.10.0 + image: dessalines/lemmy:0.10.1 ports: - "127.0.0.1:8536:8536" restart: always From 74a63804dc7ae8984e334561164214d305a361bd Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 5 Apr 2021 17:21:56 +0000 Subject: [PATCH 12/14] Fix test failure due to config loading error (#1547) * Crash if config fails to load * fix previous commit * Fix test failure due to config loading error * Adding test fix to drone. * Logging line. * Trying to fix drone 2 * Fixing deploy script. Co-authored-by: Dessalines --- .drone.yml | 2 + config/config.hjson | 90 +++++++++++++++++++++++++++++++++++++++++- config/defaults.hjson | 91 ------------------------------------------- docker/prod/deploy.sh | 3 ++ scripts/test.sh | 3 ++ 5 files changed, 97 insertions(+), 92 deletions(-) delete mode 100644 config/defaults.hjson diff --git a/.drone.yml b/.drone.yml index bb27984f9..7dd4d3e79 100644 --- a/.drone.yml +++ b/.drone.yml @@ -29,6 +29,7 @@ steps: image: ekidd/rust-musl-builder:1.50.0 environment: LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy + LEMMY_CONFIG_LOCATION: ../../config/config.hjson RUST_BACKTRACE: 1 RUST_TEST_THREADS: 1 commands: @@ -107,6 +108,7 @@ steps: image: rust:1.50-slim-buster environment: LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy + LEMMY_CONFIG_LOCATION: ../../config/config.hjson RUST_BACKTRACE: 1 RUST_TEST_THREADS: 1 commands: diff --git a/config/config.hjson b/config/config.hjson index 286b1c031..1ab231c2f 100644 --- a/config/config.hjson +++ b/config/config.hjson @@ -1,3 +1,91 @@ { - hostname: "localhost:8536" +# # optional: parameters for automatic configuration of new instance (only used at first start) +# setup: { +# # username for the admin user +# admin_username: "" +# # password for the admin user +# admin_password: "" +# # optional: email for the admin user (can be omitted and set later through the website) +# admin_email: "" +# # name of the site (can be changed later) +# site_name: "" +# } + # settings related to the postgresql database + database: { + # username to connect to postgres + user: "lemmy" + # password to connect to postgres + password: "password" + # host where postgres is running + host: "localhost" + # port where postgres can be accessed + port: 5432 + # name of the postgres database for lemmy + database: "lemmy" + # maximum number of active sql connections + pool_size: 5 + } + # the domain name of your instance (eg "lemmy.ml") + hostname: lemmy-alpha + # address where lemmy should listen for incoming requests + bind: "0.0.0.0" + # port where lemmy should listen for incoming requests + port: 8536 + # whether tls is required for activitypub. only disable this for debugging, never for producion. + tls_enabled: true + # json web token for authorization between server and client + jwt_secret: "changeme" + # address where pictrs is available + pictrs_url: "http://pictrs:8080" + # address where iframely is available + iframely_url: "http://iframely" + # rate limits for various user actions, by user ip + rate_limit: { + # maximum number of messages created in interval + message: 180 + # interval length for message limit + message_per_second: 60 + # maximum number of posts created in interval + post: 6 + # interval length for post limit + post_per_second: 600 + # maximum number of registrations in interval + register: 3 + # interval length for registration limit + register_per_second: 3600 + # maximum number of image uploads in interval + image: 6 + # interval length for image uploads + image_per_second: 3600 + } + # settings related to activitypub federation + federation: { + # whether to enable activitypub federation. + enabled: false + # Allows and blocks are described here: + # https://join.lemmy.ml/docs/en/federation/administration.html#instance-allowlist-and-blocklist + # + # comma separated list of instances with which federation is allowed + # Only one of these blocks should be uncommented + # allowed_instances: ["instance1.tld","instance2.tld"] + # comma separated list of instances which are blocked from federating + # blocked_instances: [] + } + captcha: { + enabled: true + difficulty: medium # Can be easy, medium, or hard + } +# # email sending configuration +# email: { +# # hostname and port of the smtp server +# smtp_server: "" +# # login name for smtp server +# smtp_login: "" +# # password to login to the smtp server +# smtp_password: "" +# # address to send emails from, eg "noreply@your-instance.com" +# smtp_from_address: "" +# # whether or not smtp connections should use tls +# use_tls: true +# } } diff --git a/config/defaults.hjson b/config/defaults.hjson deleted file mode 100644 index c3eaba6e5..000000000 --- a/config/defaults.hjson +++ /dev/null @@ -1,91 +0,0 @@ -{ -# # optional: parameters for automatic configuration of new instance (only used at first start) -# setup: { -# # username for the admin user -# admin_username: "" -# # password for the admin user -# admin_password: "" -# # optional: email for the admin user (can be omitted and set later through the website) -# admin_email: "" -# # name of the site (can be changed later) -# site_name: "" -# } - # settings related to the postgresql database - database: { - # username to connect to postgres - user: "lemmy" - # password to connect to postgres - password: "password" - # host where postgres is running - host: "localhost" - # port where postgres can be accessed - port: 5432 - # name of the postgres database for lemmy - database: "lemmy" - # maximum number of active sql connections - pool_size: 5 - } - # the domain name of your instance (eg "lemmy.ml") - hostname: null - # address where lemmy should listen for incoming requests - bind: "0.0.0.0" - # port where lemmy should listen for incoming requests - port: 8536 - # whether tls is required for activitypub. only disable this for debugging, never for producion. - tls_enabled: true - # json web token for authorization between server and client - jwt_secret: "changeme" - # address where pictrs is available - pictrs_url: "http://pictrs:8080" - # address where iframely is available - iframely_url: "http://iframely" - # rate limits for various user actions, by user ip - rate_limit: { - # maximum number of messages created in interval - message: 180 - # interval length for message limit - message_per_second: 60 - # maximum number of posts created in interval - post: 6 - # interval length for post limit - post_per_second: 600 - # maximum number of registrations in interval - register: 3 - # interval length for registration limit - register_per_second: 3600 - # maximum number of image uploads in interval - image: 6 - # interval length for image uploads - image_per_second: 3600 - } - # settings related to activitypub federation - federation: { - # whether to enable activitypub federation. - enabled: false - # Allows and blocks are described here: - # https://join.lemmy.ml/docs/en/federation/administration.html#instance-allowlist-and-blocklist - # - # comma separated list of instances with which federation is allowed - # Only one of these blocks should be uncommented - # allowed_instances: ["instance1.tld","instance2.tld"] - # comma separated list of instances which are blocked from federating - # blocked_instances: [] - } - captcha: { - enabled: true - difficulty: medium # Can be easy, medium, or hard - } -# # email sending configuration -# email: { -# # hostname and port of the smtp server -# smtp_server: "" -# # login name for smtp server -# smtp_login: "" -# # password to login to the smtp server -# smtp_password: "" -# # address to send emails from, eg "noreply@your-instance.com" -# smtp_from_address: "" -# # whether or not smtp connections should use tls -# use_tls: true -# } -} diff --git a/docker/prod/deploy.sh b/docker/prod/deploy.sh index bd99fdb09..b2ee16635 100755 --- a/docker/prod/deploy.sh +++ b/docker/prod/deploy.sh @@ -13,7 +13,9 @@ git add "crates/utils/src/version.rs" popd # Changing various references to the Lemmy version +sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../dev/docker-compose.yml sed -i "s/dessalines\/lemmy-ui:.*/dessalines\/lemmy-ui:$new_tag/" ../dev/docker-compose.yml +sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../federation/docker-compose.yml sed -i "s/dessalines\/lemmy-ui:.*/dessalines\/lemmy-ui:$new_tag/" ../federation/docker-compose.yml git add ../dev/docker-compose.yml git add ../federation/docker-compose.yml @@ -22,6 +24,7 @@ git add ../federation/docker-compose.yml # IE, when the third semver is a number, not '2-rc' if [ ! -z "${third_semver##*[!0-9]*}" ]; then sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../prod/docker-compose.yml + sed -i "s/dessalines\/lemmy-ui:.*/dessalines\/lemmy-ui:$new_tag/" ../prod/docker-compose.yml git add ../prod/docker-compose.yml # Setting the version for Ansible diff --git a/scripts/test.sh b/scripts/test.sh index 251e6a74a..0a3fa90fc 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -5,5 +5,8 @@ psql -U lemmy -d postgres -c "DROP DATABASE lemmy;" psql -U lemmy -d postgres -c "CREATE DATABASE lemmy;" export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy +# tests are executed in working directory crates/api (or similar), +# so to load the config we need to traverse to the repo root +export LEMMY_CONFIG_LOCATION=../../config/config.hjson RUST_BACKTRACE=1 \ cargo test --workspace --no-fail-fast From 89b96511bffbb0a3518f7f03890b12a56d969032 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 5 Apr 2021 13:21:08 -0400 Subject: [PATCH 13/14] Version 0.10.2 --- ansible/VERSION | 2 +- crates/utils/src/version.rs | 2 +- docker/dev/docker-compose.yml | 2 +- docker/federation/docker-compose.yml | 10 +++++----- docker/prod/docker-compose.yml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ansible/VERSION b/ansible/VERSION index 571215736..5eef0f10e 100644 --- a/ansible/VERSION +++ b/ansible/VERSION @@ -1 +1 @@ -0.10.1 +0.10.2 diff --git a/crates/utils/src/version.rs b/crates/utils/src/version.rs index b83fff578..476a14bd4 100644 --- a/crates/utils/src/version.rs +++ b/crates/utils/src/version.rs @@ -1 +1 @@ -pub const VERSION: &str = "0.10.1"; +pub const VERSION: &str = "0.10.2"; diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index 071bdf29c..2df7f28cf 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -17,7 +17,7 @@ services: - iframely lemmy-ui: - image: dessalines/lemmy-ui:0.10.1 + image: dessalines/lemmy-ui:0.10.2 ports: - "1235:1234" restart: always diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 760fbe3b2..ee6e2d27d 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -29,7 +29,7 @@ services: - ./volumes/pictrs_alpha:/mnt lemmy-alpha-ui: - image: dessalines/lemmy-ui:0.10.1 + image: dessalines/lemmy-ui:0.10.2 environment: - LEMMY_INTERNAL_HOST=lemmy-alpha:8541 - LEMMY_EXTERNAL_HOST=localhost:8541 @@ -58,7 +58,7 @@ services: - ./volumes/postgres_alpha:/var/lib/postgresql/data lemmy-beta-ui: - image: dessalines/lemmy-ui:0.10.1 + image: dessalines/lemmy-ui:0.10.2 environment: - LEMMY_INTERNAL_HOST=lemmy-beta:8551 - LEMMY_EXTERNAL_HOST=localhost:8551 @@ -87,7 +87,7 @@ services: - ./volumes/postgres_beta:/var/lib/postgresql/data lemmy-gamma-ui: - image: dessalines/lemmy-ui:0.10.1 + image: dessalines/lemmy-ui:0.10.2 environment: - LEMMY_INTERNAL_HOST=lemmy-gamma:8561 - LEMMY_EXTERNAL_HOST=localhost:8561 @@ -117,7 +117,7 @@ services: # An instance with only an allowlist for beta lemmy-delta-ui: - image: dessalines/lemmy-ui:0.10.1 + image: dessalines/lemmy-ui:0.10.2 environment: - LEMMY_INTERNAL_HOST=lemmy-delta:8571 - LEMMY_EXTERNAL_HOST=localhost:8571 @@ -147,7 +147,7 @@ services: # An instance who has a blocklist, with lemmy-alpha blocked lemmy-epsilon-ui: - image: dessalines/lemmy-ui:0.10.1 + image: dessalines/lemmy-ui:0.10.2 environment: - LEMMY_INTERNAL_HOST=lemmy-epsilon:8581 - LEMMY_EXTERNAL_HOST=localhost:8581 diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml index c1556dd9b..5e617c6cc 100644 --- a/docker/prod/docker-compose.yml +++ b/docker/prod/docker-compose.yml @@ -12,7 +12,7 @@ services: restart: always lemmy: - image: dessalines/lemmy:0.10.1 + image: dessalines/lemmy:0.10.2 ports: - "127.0.0.1:8536:8536" restart: always @@ -26,7 +26,7 @@ services: - iframely lemmy-ui: - image: dessalines/lemmy-ui:0.9.9 + image: dessalines/lemmy-ui:0.10.2 ports: - "127.0.0.1:1235:1234" restart: always From df7fe705eb16468eb310f71a86555098dede758a Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 5 Apr 2021 13:26:24 -0400 Subject: [PATCH 14/14] Updating releases.md --- RELEASES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 8f9e44e21..95b458240 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,7 @@ +# Lemmy v0.10.2 Release (2021-04-05) + +- Forcing a crash if config.hjson fails to load. Should show errors easier. + # Lemmy v0.10.0 Release (2021-04-05) ## Changes