From e31f74c3ad354f4401e8ce0b0f65de8d1d8ebe41 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 30 Jul 2020 11:51:28 -0400 Subject: [PATCH 1/4] Add domain name change instructions to docs. (#1044) * Add domain name change instructions to docs. * Changing docker execs to docker-compose execs --- docs/src/administration_backup_and_restore.md | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/docs/src/administration_backup_and_restore.md b/docs/src/administration_backup_and_restore.md index fe97cf880..633c687fb 100644 --- a/docs/src/administration_backup_and_restore.md +++ b/docs/src/administration_backup_and_restore.md @@ -9,14 +9,14 @@ When using docker or ansible, there should be a `volumes` folder, which contains To incrementally backup the DB to an `.sql` file, you can run: ```bash -docker exec -t FOLDERNAME_postgres_1 pg_dumpall -c -U lemmy > lemmy_dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql +docker-compose exec postgres pg_dumpall -c -U lemmy > lemmy_dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql ``` ### A Sample backup script ```bash #!/bin/sh # DB Backup -ssh MY_USER@MY_IP "docker exec -t FOLDERNAME_postgres_1 pg_dumpall -c -U lemmy" > ~/BACKUP_LOCATION/INSTANCE_NAME_dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql +ssh MY_USER@MY_IP "docker-compose exec postgres pg_dumpall -c -U lemmy" > ~/BACKUP_LOCATION/INSTANCE_NAME_dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql # Volumes folder Backup rsync -avP -zz --rsync-path="sudo rsync" MY_USER@MY_IP:/LEMMY_LOCATION/volumes ~/BACKUP_LOCATION/FOLDERNAME @@ -37,6 +37,45 @@ cat db_dump.sql | docker exec -i FOLDERNAME_postgres_1 psql -U lemmy # restore docker exec -i FOLDERNAME_postgres_1 psql -U lemmy -c "alter user lemmy with password 'bleh'" ``` +### Changing your domain name + +If you haven't federated yet, you can change your domain name in the DB. **Warning: do not do this after you've federated, or it will break federation.** + +Get into `psql` for your docker: + +`docker-compose exec postgres psql -U lemmy` + +``` +-- Post +update post set ap_id = replace (ap_id, 'old_domain', 'new_domain'); +update post set url = replace (url, 'old_domain', 'new_domain'); +update post set body = replace (body, 'old_domain', 'new_domain'); +update post set thumbnail_url = replace (thumbnail_url, 'old_domain', 'new_domain'); + +delete from post_aggregates_fast; +insert into post_aggregates_fast select * from post_aggregates_view; + +-- Comments +update comment set ap_id = replace (ap_id, 'old_domain', 'new_domain'); +update comment set content = replace (content, 'old_domain', 'new_domain'); + +delete from comment_aggregates_fast; +insert into comment_aggregates_fast select * from comment_aggregates_view; + +-- User +update user_ set actor_id = replace (actor_id, 'old_domain', 'new_domain'); +update user_ set avatar = replace (avatar, 'old_domain', 'new_domain'); + +delete from user_fast; +insert into user_fast select * from user_view; + +-- Community +update community set actor_id = replace (actor_id, 'old_domain', 'new_domain'); + +delete from community_aggregates_fast; +insert into community_aggregates_fast select * from community_aggregates_view; +``` + ## More resources - https://stackoverflow.com/questions/24718706/backup-restore-a-dockerized-postgresql-database From 1acb51105a3316ab52f7d65970839a766899ad14 Mon Sep 17 00:00:00 2001 From: Azriel Lector Date: Fri, 31 Jul 2020 09:08:13 +0800 Subject: [PATCH 2/4] Add user bios (#1043) * Add user bios * Version v0.7.35 * Add domain name change instructions to docs. (#1044) * Add domain name change instructions to docs. * Changing docker execs to docker-compose execs * Set maxLength to user bio and render as md * Fix bio updating after SaveUserSetting Co-authored-by: Dessalines Co-authored-by: Dessalines --- .gitignore | 1 + server/src/api/user.rs | 14 ++++++++- ui/src/components/markdown-textarea.tsx | 3 +- ui/src/components/user.tsx | 40 +++++++++++++++++++++++-- ui/src/interfaces.ts | 1 + ui/translations/en.json | 4 ++- 6 files changed, 57 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 6ae0ae193..c3a8bd70e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,6 @@ ui/src/translations # ide config .idea/ +.vscode/ target diff --git a/server/src/api/user.rs b/server/src/api/user.rs index c2b6955b5..f9a92cd39 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -97,6 +97,7 @@ pub struct SaveUserSettings { lang: String, avatar: Option, email: Option, + bio: Option, matrix_user_id: Option, new_password: Option, new_password_verify: Option, @@ -557,6 +558,17 @@ impl Perform for Oper { None => read_user.email, }; + let bio = match &data.bio { + Some(bio) => { + if bio.chars().count() <= 300 { + Some(bio.to_owned()) + } else { + return Err(APIError::err("bio_length_overflow").into()); + } + } + None => read_user.bio, + }; + let avatar = match &data.avatar { Some(avatar) => Some(avatar.to_owned()), None => read_user.avatar, @@ -613,7 +625,7 @@ impl Perform for Oper { show_avatars: data.show_avatars, send_notifications_to_email: data.send_notifications_to_email, actor_id: read_user.actor_id, - bio: read_user.bio, + bio, local: read_user.local, private_key: read_user.private_key, public_key: read_user.public_key, diff --git a/ui/src/components/markdown-textarea.tsx b/ui/src/components/markdown-textarea.tsx index 237ef9ff3..002d7c86b 100644 --- a/ui/src/components/markdown-textarea.tsx +++ b/ui/src/components/markdown-textarea.tsx @@ -21,6 +21,7 @@ interface MarkdownTextAreaProps { replyType?: boolean; focus?: boolean; disabled?: boolean; + maxLength?: number; onSubmit?(msg: { val: string; formId: string }): any; onContentChange?(val: string): any; onReplyCancel?(): any; @@ -121,7 +122,7 @@ export class MarkdownTextArea extends Component< required disabled={this.props.disabled} rows={2} - maxLength={10000} + maxLength={this.props.maxLength || 10000} /> {this.state.previewMode && (
{ show_avatars: null, send_notifications_to_email: null, auth: null, + bio: null, }, userSettingsLoading: null, deleteAccountLoading: null, @@ -149,7 +152,13 @@ export class User extends Component { this.handleUserSettingsListingTypeChange = this.handleUserSettingsListingTypeChange.bind( this ); + this.handleUserSettingsListingTypeChange = this.handleUserSettingsListingTypeChange.bind( + this + ); this.handlePageChange = this.handlePageChange.bind(this); + this.handleUserSettingsBioChange = this.handleUserSettingsBioChange.bind( + this + ); this.state.user_id = Number(this.props.match.params.id) || null; this.state.username = this.props.match.params.username; @@ -375,6 +384,12 @@ export class User extends Component { )} +
+
+
@@ -570,6 +585,18 @@ export class User extends Component { />
+
+ +
+ +
+