to_json_string(&user_operation, &res)
}
UserOperation::ListCommunities => {
- do_user_operation::<ListCommunities, ListCommunitiesResponse>(user_operation, data, &conn)
+ if Settings::get().federation_enabled {
+ let res = get_all_communities()?;
+ let val = ListCommunitiesResponse { communities: res };
+ to_json_string(&user_operation, &val)
+ } else {
+ do_user_operation::<ListCommunities, ListCommunitiesResponse>(user_operation, data, &conn)
+ }
}
UserOperation::CreateCommunity => {
- chat.check_rate_limit_register(msg.id)?;
- do_user_operation::<CreateCommunity, CommunityResponse>(user_operation, data, &conn)
+ chat.check_rate_limit_register(msg.id, true)?;
+ let create_community: CreateCommunity = serde_json::from_str(data)?;
+ let res = Oper::new(create_community).perform(&conn)?;
+ chat.check_rate_limit_register(msg.id, false)?;
+ to_json_string(&user_operation, &res)
}
UserOperation::EditCommunity => {
let edit_community: EditCommunity = serde_json::from_str(data)?;