let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
// Check for a community ban
let post = Post::read(&conn, data.post_id)?;
if CommunityUserBanView::get(&conn, user_id, post.community_id).is_ok() {
- return Err(APIError::err(&self.op, "You have been banned from this community"))?
+ return Err(APIError::err(&self.op, "community_ban"))?
}
// Check for a site ban
if UserView::read(&conn, user_id)?.banned {
- return Err(APIError::err(&self.op, "You have been banned from the site"))?
+ return Err(APIError::err(&self.op, "site_ban"))?
}
let content_slurs_removed = remove_slurs(&data.content.to_owned());
let inserted_comment = match Comment::create(&conn, &comment_form) {
Ok(comment) => comment,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't create Comment"))?
+ return Err(APIError::err(&self.op, "couldnt_create_comment"))?
}
};
let _inserted_like = match CommentLike::like(&conn, &like_form) {
Ok(like) => like,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't like comment."))?
+ return Err(APIError::err(&self.op, ""))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
);
if !editors.contains(&user_id) {
- return Err(APIError::err(&self.op, "Not allowed to edit comment."))?
+ return Err(APIError::err(&self.op, "no_comment_edit_allowed"))?
}
// Check for a community ban
if CommunityUserBanView::get(&conn, user_id, orig_comment.community_id).is_ok() {
- return Err(APIError::err(&self.op, "You have been banned from this community"))?
+ return Err(APIError::err(&self.op, "community_ban"))?
}
// Check for a site ban
if UserView::read(&conn, user_id)?.banned {
- return Err(APIError::err(&self.op, "You have been banned from the site"))?
+ return Err(APIError::err(&self.op, "site_ban"))?
}
}
let _updated_comment = match Comment::update(&conn, data.edit_id, &comment_form) {
Ok(comment) => comment,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't update Comment"))?
+ return Err(APIError::err(&self.op, "couldnt_update_comment"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
match CommentSaved::save(&conn, &comment_saved_form) {
Ok(comment) => comment,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldnt do comment save"))?
+ return Err(APIError::err(&self.op, "couldnt_save_comment"))?
}
};
} else {
match CommentSaved::unsave(&conn, &comment_saved_form) {
Ok(comment) => comment,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldnt do comment save"))?
+ return Err(APIError::err(&self.op, "couldnt_save_comment"))?
}
};
}
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
// Check for a community ban
let post = Post::read(&conn, data.post_id)?;
if CommunityUserBanView::get(&conn, user_id, post.community_id).is_ok() {
- return Err(APIError::err(&self.op, "You have been banned from this community"))?
+ return Err(APIError::err(&self.op, "community_ban"))?
}
// Check for a site ban
if UserView::read(&conn, user_id)?.banned {
- return Err(APIError::err(&self.op, "You have been banned from the site"))?
+ return Err(APIError::err(&self.op, "site_ban"))?
}
let like_form = CommentLikeForm {
let _inserted_like = match CommentLike::like(&conn, &like_form) {
Ok(like) => like,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't like comment."))?
+ return Err(APIError::err(&self.op, "couldnt_like_comment"))?
}
};
}
let community_view = match CommunityView::read(&conn, community_id, user_id) {
Ok(community) => community,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't find Community"))?
+ return Err(APIError::err(&self.op, "couldnt_find_community"))?
}
};
let moderators = match CommunityModeratorView::for_community(&conn, community_id) {
Ok(moderators) => moderators,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't find Community"))?
+ return Err(APIError::err(&self.op, "couldnt_find_community"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
if has_slurs(&data.name) ||
has_slurs(&data.title) ||
(data.description.is_some() && has_slurs(&data.description.to_owned().unwrap())) {
- return Err(APIError::err(&self.op, "No slurs"))?
+ return Err(APIError::err(&self.op, "no_slurs"))?
}
let user_id = claims.id;
// Check for a site ban
if UserView::read(&conn, user_id)?.banned {
- return Err(APIError::err(&self.op, "You have been banned from the site"))?
+ return Err(APIError::err(&self.op, "site_ban"))?
}
// When you create a community, make sure the user becomes a moderator and a follower
let inserted_community = match Community::create(&conn, &community_form) {
Ok(community) => community,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community already exists."))?
+ return Err(APIError::err(&self.op, "community_already_exists"))?
}
};
let _inserted_community_moderator = match CommunityModerator::join(&conn, &community_moderator_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community moderator already exists."))?
+ return Err(APIError::err(&self.op, "community_moderator_already_exists"))?
}
};
let _inserted_community_follower = match CommunityFollower::follow(&conn, &community_follower_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community follower already exists."))?
+ return Err(APIError::err(&self.op, "community_follower_already_exists"))?
}
};
let data: &EditCommunity = &self.data;
if has_slurs(&data.name) || has_slurs(&data.title) {
- return Err(APIError::err(&self.op, "No slurs"))?
+ return Err(APIError::err(&self.op, "no_slurs"))?
}
let conn = establish_connection();
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
// Check for a site ban
if UserView::read(&conn, user_id)?.banned {
- return Err(APIError::err(&self.op, "You have been banned from the site"))?
+ return Err(APIError::err(&self.op, "site_ban"))?
}
// Verify its a mod
.collect()
);
if !editors.contains(&user_id) {
- return Err(APIError::err(&self.op, "Not allowed to edit community"))?
+ return Err(APIError::err(&self.op, "no_community_edit_allowed"))?
}
let community_form = CommunityForm {
let _updated_community = match Community::update(&conn, data.edit_id, &community_form) {
Ok(community) => community,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't update Community"))?
+ return Err(APIError::err(&self.op, "couldnt_update_community"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
match CommunityFollower::follow(&conn, &community_follower_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community follower already exists."))?
+ return Err(APIError::err(&self.op, "community_follower_already_exists"))?
}
};
} else {
match CommunityFollower::ignore(&conn, &community_follower_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community follower already exists."))?
+ return Err(APIError::err(&self.op, "community_follower_already_exists"))?
}
};
}
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
let communities: Vec<CommunityFollowerView> = match CommunityFollowerView::for_user(&conn, user_id) {
Ok(communities) => communities,
Err(_e) => {
- return Err(APIError::err(&self.op, "System error, try logging out and back in."))?
+ return Err(APIError::err(&self.op, "system_err_login"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
match CommunityUserBan::ban(&conn, &community_user_ban_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community user ban already exists"))?
+ return Err(APIError::err(&self.op, "community_user_already_banned"))?
}
};
} else {
match CommunityUserBan::unban(&conn, &community_user_ban_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community user ban already exists"))?
+ return Err(APIError::err(&self.op, "community_user_already_banned"))?
}
};
}
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
match CommunityModerator::join(&conn, &community_moderator_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community moderator already exists."))?
+ return Err(APIError::err(&self.op, "community_moderator_already_exists"))?
}
};
} else {
match CommunityModerator::leave(&conn, &community_moderator_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community moderator already exists."))?
+ return Err(APIError::err(&self.op, "community_moderator_already_exists"))?
}
};
}
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
if has_slurs(&data.name) ||
(data.body.is_some() && has_slurs(&data.body.to_owned().unwrap())) {
- return Err(APIError::err(&self.op, "No slurs"))?
+ return Err(APIError::err(&self.op, "no_slurs"))?
}
let user_id = claims.id;
// Check for a community ban
if CommunityUserBanView::get(&conn, user_id, data.community_id).is_ok() {
- return Err(APIError::err(&self.op, "You have been banned from this community"))?
+ return Err(APIError::err(&self.op, "community_ban"))?
}
// Check for a site ban
if UserView::read(&conn, user_id)?.banned {
- return Err(APIError::err(&self.op, "You have been banned from the site"))?
+ return Err(APIError::err(&self.op, "site_ban"))?
}
let post_form = PostForm {
let inserted_post = match Post::create(&conn, &post_form) {
Ok(post) => post,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't create Post"))?
+ return Err(APIError::err(&self.op, "couldnt_create_post"))?
}
};
let _inserted_like = match PostLike::like(&conn, &like_form) {
Ok(like) => like,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't like post."))?
+ return Err(APIError::err(&self.op, "couldnt_like_post"))?
}
};
let post_view = match PostView::read(&conn, inserted_post.id, Some(user_id)) {
Ok(post) => post,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't find Post"))?
+ return Err(APIError::err(&self.op, "couldnt_find_post"))?
}
};
let post_view = match PostView::read(&conn, data.id, user_id) {
Ok(post) => post,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't find Post"))?
+ return Err(APIError::err(&self.op, "couldnt_find_post"))?
}
};
data.limit) {
Ok(posts) => posts,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't get posts"))?
+ return Err(APIError::err(&self.op, "couldnt_get_posts"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
// Check for a community ban
let post = Post::read(&conn, data.post_id)?;
if CommunityUserBanView::get(&conn, user_id, post.community_id).is_ok() {
- return Err(APIError::err(&self.op, "You have been banned from this community"))?
+ return Err(APIError::err(&self.op, "community_ban"))?
}
// Check for a site ban
if UserView::read(&conn, user_id)?.banned {
- return Err(APIError::err(&self.op, "You have been banned from the site"))?
+ return Err(APIError::err(&self.op, "site_ban"))?
}
let like_form = PostLikeForm {
let _inserted_like = match PostLike::like(&conn, &like_form) {
Ok(like) => like,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't like post."))?
+ return Err(APIError::err(&self.op, "couldnt_like_post"))?
}
};
}
let post_view = match PostView::read(&conn, data.post_id, Some(user_id)) {
Ok(post) => post,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't find Post"))?
+ return Err(APIError::err(&self.op, "couldnt_find_post"))?
}
};
let data: &EditPost = &self.data;
if has_slurs(&data.name) ||
(data.body.is_some() && has_slurs(&data.body.to_owned().unwrap())) {
- return Err(APIError::err(&self.op, "No slurs"))?
+ return Err(APIError::err(&self.op, "no_slurs"))?
}
let conn = establish_connection();
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
.collect()
);
if !editors.contains(&user_id) {
- return Err(APIError::err(&self.op, "Not allowed to edit post."))?
+ return Err(APIError::err(&self.op, "no_post_edit_allowed"))?
}
// Check for a community ban
if CommunityUserBanView::get(&conn, user_id, data.community_id).is_ok() {
- return Err(APIError::err(&self.op, "You have been banned from this community"))?
+ return Err(APIError::err(&self.op, "community_ban"))?
}
// Check for a site ban
if UserView::read(&conn, user_id)?.banned {
- return Err(APIError::err(&self.op, "You have been banned from the site"))?
+ return Err(APIError::err(&self.op, "site_ban"))?
}
let post_form = PostForm {
let _updated_post = match Post::update(&conn, data.edit_id, &post_form) {
Ok(post) => post,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't update Post"))?
+ return Err(APIError::err(&self.op, "couldnt_update_post"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
match PostSaved::save(&conn, &post_saved_form) {
Ok(post) => post,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldnt do post save"))?
+ return Err(APIError::err(&self.op, "couldnt_save_post"))?
}
};
} else {
match PostSaved::unsave(&conn, &post_saved_form) {
Ok(post) => post,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldnt do post save"))?
+ return Err(APIError::err(&self.op, "couldnt_save_post"))?
}
};
}
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
if has_slurs(&data.name) ||
(data.description.is_some() && has_slurs(&data.description.to_owned().unwrap())) {
- return Err(APIError::err(&self.op, "No slurs"))?
+ return Err(APIError::err(&self.op, "no_slurs"))?
}
let user_id = claims.id;
// Make sure user is an admin
if !UserView::read(&conn, user_id)?.admin {
- return Err(APIError::err(&self.op, "Not an admin."))?
+ return Err(APIError::err(&self.op, "not_an_admin"))?
}
let site_form = SiteForm {
match Site::create(&conn, &site_form) {
Ok(site) => site,
Err(_e) => {
- return Err(APIError::err(&self.op, "Site exists already"))?
+ return Err(APIError::err(&self.op, "site_already_exists"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
if has_slurs(&data.name) ||
(data.description.is_some() && has_slurs(&data.description.to_owned().unwrap())) {
- return Err(APIError::err(&self.op, "No slurs"))?
+ return Err(APIError::err(&self.op, "no_slurs"))?
}
let user_id = claims.id;
// Make sure user is an admin
if UserView::read(&conn, user_id)?.admin == false {
- return Err(APIError::err(&self.op, "Not an admin."))?
+ return Err(APIError::err(&self.op, "not_an_admin"))?
}
let found_site = Site::read(&conn, 1)?;
match Site::update(&conn, 1, &site_form) {
Ok(site) => site,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't update site."))?
+ return Err(APIError::err(&self.op, "couldnt_update_site"))?
}
};
// Fetch that username / email
let user: User_ = match User_::find_by_email_or_username(&conn, &data.username_or_email) {
Ok(user) => user,
- Err(_e) => return Err(APIError::err(&self.op, "Couldn't find that username or email"))?
+ Err(_e) => return Err(APIError::err(&self.op, "couldnt_find_that_username_or_email"))?
};
// Verify the password
let valid: bool = verify(&data.password, &user.password_encrypted).unwrap_or(false);
if !valid {
- return Err(APIError::err(&self.op, "Password incorrect"))?
+ return Err(APIError::err(&self.op, "password_incorrect"))?
}
// Return the jwt
// Make sure passwords match
if &data.password != &data.password_verify {
- return Err(APIError::err(&self.op, "Passwords do not match."))?
+ return Err(APIError::err(&self.op, "passwords_dont_match"))?
}
if has_slurs(&data.username) {
- return Err(APIError::err(&self.op, "No slurs"))?
+ return Err(APIError::err(&self.op, "no_slurs"))?
}
// Make sure there are no admins
if data.admin && UserView::admins(&conn)?.len() > 0 {
- return Err(APIError::err(&self.op, "Sorry, there's already an admin."))?
+ return Err(APIError::err(&self.op, "admin_already_created"))?
}
// Register the new user
let inserted_user = match User_::register(&conn, &user_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "User already exists."))?
+ return Err(APIError::err(&self.op, "user_already_exists"))?
}
};
let _inserted_community_follower = match CommunityFollower::follow(&conn, &community_follower_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community follower already exists."))?
+ return Err(APIError::err(&self.op, "community_follower_already_exists"))?
}
};
let _inserted_community_moderator = match CommunityModerator::join(&conn, &community_moderator_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Community moderator already exists."))?
+ return Err(APIError::err(&self.op, "community_moderator_already_exists"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
// Make sure user is an admin
if UserView::read(&conn, user_id)?.admin == false {
- return Err(APIError::err(&self.op, "Not an admin."))?
+ return Err(APIError::err(&self.op, "not_an_admin"))?
}
let read_user = User_::read(&conn, data.user_id)?;
match User_::update(&conn, data.user_id, &user_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't update user"))?
+ return Err(APIError::err(&self.op, "couldnt_update_user"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
// Make sure user is an admin
if UserView::read(&conn, user_id)?.admin == false {
- return Err(APIError::err(&self.op, "Not an admin."))?
+ return Err(APIError::err(&self.op, "not_an_admin"))?
}
let read_user = User_::read(&conn, data.user_id)?;
match User_::update(&conn, data.user_id, &user_form) {
Ok(user) => user,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't update user"))?
+ return Err(APIError::err(&self.op, "couldnt_update_user"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
let claims = match Claims::decode(&data.auth) {
Ok(claims) => claims.claims,
Err(_e) => {
- return Err(APIError::err(&self.op, "Not logged in."))?
+ return Err(APIError::err(&self.op, "not_logged_in"))?
}
};
let _updated_comment = match Comment::update(&conn, reply.id, &comment_form) {
Ok(comment) => comment,
Err(_e) => {
- return Err(APIError::err(&self.op, "Couldn't update Comment"))?
+ return Err(APIError::err(&self.op, "couldnt_update_comment"))?
}
};
}
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
return;
} else if (op == UserOperation.ListCommunities) {
let res: ListCommunitiesResponse = msg;
let op: UserOperation = msgOp(msg);
console.log(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
this.state.loading = false;
this.setState(this.state);
return;
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
return;
} else if (op == UserOperation.GetCommunity) {
let res: GetCommunityResponse = msg;
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
return;
} else if (op == UserOperation.GetReplies || op == UserOperation.MarkAllAsRead) {
let res: GetRepliesResponse = msg;
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
this.state = this.emptyState;
this.setState(this.state);
return;
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
return;
} else if (op == UserOperation.GetFollowedCommunities) {
let res: GetFollowedCommunitiesResponse = msg;
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
return;
} else if (op == UserOperation.GetModlog) {
let res: GetModlogResponse = msg;
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
this.state.loading = false;
this.setState(this.state);
return;
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
return;
} else if (op == UserOperation.GetPost) {
let res: GetPostResponse = msg;
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
return;
} else if (op == UserOperation.Search) {
let res: SearchResponse = msg;
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
this.state.userLoading = false;
this.setState(this.state);
return;
console.log(msg);
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
return;
} else if (op == UserOperation.GetUserDetails) {
let res: UserDetailsResponse = msg;
import { Subject } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import { UserService } from './';
+import { i18n } from '../i18next';
export class WebSocketService {
private static _instance: WebSocketService;
private setAuth(obj: any, throwErr: boolean = true) {
obj.auth = UserService.Instance.auth;
if (obj.auth == null && throwErr) {
- alert("Not logged in.");
+ alert(i18n.t('not_logged_in'));
throw "Not logged in";
}
}
joined: 'Joined',
powered_by: 'Powered by',
landing_0: 'Lemmy is a <1>link aggregator</1> / reddit alternative, intended to work in the <2>fediverse</2>.<3></3>Its self-hostable, has live-updating comment threads, and is tiny (<4>~80kB</4>). Federation into the ActivityPub network is on the roadmap. <5></5>This is a <6>very early beta version</6>, and a lot of features are currently broken or missing. <7></7>Suggest new features or report bugs <8>here.</8><9></9>Made with <10>Rust</10>, <11>Actix</11>, <12>Inferno</12>, <13>Typescript</13>.',
+ not_logged_in: 'Not logged in.',
+ community_ban: 'You have been banned from this community.',
+ site_ban: 'You have been banned from the site',
+ couldnt_create_comment: 'Couldn\'t create comment.',
+ couldnt_like_comment: 'Couldn\'t like comment.',
+ couldnt_update_comment: 'Couldn\'t update comment.',
+ couldnt_save_comment: 'Couldn\'t save comment.',
+ no_comment_edit_allowed: 'Not allowed to edit comment.',
+ no_post_edit_allowed: 'Not allowed to edit post.',
+ no_community_edit_allowed: 'Not allowed to edit community.',
+ couldnt_find_community: 'Couldn\'t find community.',
+ couldnt_update_community: 'Couldn\'t update Community.',
+ community_already_exists: 'Community already exists.',
+ community_moderator_already_exists: 'Community moderator already exists.',
+ community_follower_already_exists: 'Community follower already exists.',
+ community_user_already_banned: 'Community user already banned.',
+ couldnt_create_post: 'Couldn\'t create post.',
+ couldnt_like_post: 'Couldn\'t like post.',
+ couldnt_find_post: 'Couldn\'t find post.',
+ couldnt_get_posts: 'Couldn\'t get posts',
+ couldnt_update_post: 'Couldn\'t update post',
+ couldnt_save_post: 'Couldn\'t save post.',
+ no_slurs: 'No slurs.',
+ not_an_admin: 'Not an admin.',
+ site_already_exists: 'Site already exists.',
+ couldnt_update_site: 'Couldn\'t update site.',
+ couldnt_find_that_username_or_email: 'Couldn\'t find that username or email.',
+ password_incorrect: 'Password incorrect.',
+ passwords_dont_match: 'Passwords do not match.',
+ admin_already_created: 'Sorry, there\'s already an admin.',
+ user_already_exists: 'User already exists.',
+ couldnt_update_user: 'Couldn\'t update user.',
+ system_err_login: 'System error. Try logging out and back in.',
},
}
# yarn lockfile v1
-"@babel/runtime@^7.1.2", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5":
+"@babel/runtime@^7.1.2", "@babel/runtime@^7.3.1":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132"
integrity sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ==
jsprim "^1.2.2"
sshpk "^1.7.0"
-i18next-browser-languagedetector@^3.0.3:
- version "3.0.3"
- resolved "https://registry.yarnpkg.com/i18next-browser-languagedetector/-/i18next-browser-languagedetector-3.0.3.tgz#879ebe421685c70cc5cfa96191364a35ea7da742"
- integrity sha512-1YuAogyQap0J6N4kM+6gAjZ6T7QWrp3xZCmSs0QedkNmgAKhj7FiQlCviHKl3IwbM6zJNgft4D7UDPWb1dTCMQ==
-
-i18next-xhr-backend@^3.1.1:
- version "3.1.1"
- resolved "https://registry.yarnpkg.com/i18next-xhr-backend/-/i18next-xhr-backend-3.1.1.tgz#9221ba6911d466c38693fd43eb8ff10b48d3438a"
- integrity sha512-Fui5puKb1pD+Z1+biwzA9jPQTvwOgz8SOkwu7yGRorCQraOgKxp86T310HoUM2CR9VV0MM2pJdntEQrgC45+RA==
- dependencies:
- "@babel/runtime" "^7.5.5"
-
i18next@^17.0.9:
version "17.0.9"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-17.0.9.tgz#5f835e91a34fa5e7da1e5ae4c4586c81d7c4b17f"