- // Update in local database
- let community_moderator_form = CommunityModeratorForm {
- community_id: data.community_id,
- person_id: data.person_id,
- };
- if data.added {
- let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form);
- blocking(context.pool(), join)
- .await?
- .map_err(|e| LemmyError::from_error_message(e, "community_moderator_already_exists"))?;
- } else {
- let leave = move |conn: &'_ _| CommunityModerator::leave(conn, &community_moderator_form);
- blocking(context.pool(), leave)
- .await?
- .map_err(|e| LemmyError::from_error_message(e, "community_moderator_already_exists"))?;
- }
+ // Mod tables
+ let form = ModAddCommunityForm {
+ mod_person_id: local_user_view.person.id,
+ other_person_id: data.person_id,
+ community_id: data.community_id,
+ removed: Some(!data.added),
+ };