pub mod ai;
pub mod category;
pub mod draft_and_history;
pub mod member;
pub mod message;
pub mod notification;
pub mod pin;
pub mod reaction;
pub mod room;
pub mod thread;
pub mod ws;
pub mod ws_handler;
pub mod ws_types;
pub mod ws_universal;

use actix_web::web;

pub fn init_room_routes(cfg: &mut web::ServiceConfig) {
    cfg.service(
        web::scope("")
            .route(
                "/project_room/{project_name}/rooms",
                web::get().to(room::room_list),
            )
            .route(
                "/project_room/{project_name}/rooms",
                web::post().to(room::room_create),
            )
            .route(
                "/project_room/{project_name}/room-categories",
                web::get().to(category::category_list),
            )
            .route(
                "/project_room/{project_name}/room-categories",
                web::post().to(category::category_create),
            )
            .route("/rooms/{room_id}", web::get().to(room::room_get))
            .route("/rooms/{room_id}", web::patch().to(room::room_update))
            .route("/rooms/{room_id}", web::delete().to(room::room_delete))
            .route(
                "/rooms/{room_id}/messages",
                web::get().to(message::message_list),
            )
            .route(
                "/rooms/{room_id}/messages",
                web::post().to(message::message_create),
            )
            .route(
                "/rooms/{room_id}/messages/{message_id}",
                web::patch().to(message::message_update),
            )
            .route(
                "/rooms/{room_id}/messages/{message_id}",
                web::get().to(message::message_get),
            )
            .route(
                "/rooms/{room_id}/messages/{message_id}/revoke",
                web::post().to(message::message_revoke),
            )
            // room pins
            .route("/rooms/{room_id}/pins", web::get().to(pin::pin_list))
            .route(
                "/rooms/{room_id}/messages/{message_id}/pin",
                web::post().to(pin::pin_add),
            )
            .route(
                "/rooms/{room_id}/messages/{message_id}/pin",
                web::delete().to(pin::pin_remove),
            )
            // room threads
            .route(
                "/rooms/{room_id}/threads",
                web::get().to(thread::thread_list),
            )
            .route(
                "/rooms/{room_id}/threads",
                web::post().to(thread::thread_create),
            )
            .route(
                "/rooms/{room_id}/threads/{thread_id}/messages",
                web::get().to(thread::thread_messages),
            )
            // room members
            .route(
                "/rooms/{room_id}/members",
                web::get().to(member::member_list),
            )
            .route(
                "/rooms/{room_id}/members",
                web::post().to(member::member_add),
            )
            .route(
                "/rooms/{room_id}/members/{user_id}",
                web::delete().to(member::member_remove),
            )
            .route(
                "/rooms/{room_id}/members/me",
                web::delete().to(member::member_leave),
            )
            .route(
                "/rooms/{room_id}/members/me/read-seq",
                web::patch().to(member::member_set_read_seq),
            )
            .route(
                "/rooms/{room_id}/members/{user_id}/role",
                web::patch().to(member::member_update_role),
            )
            // room reactions
            .route(
                "/rooms/{room_id}/messages/{message_id}/reactions",
                web::post().to(reaction::reaction_add),
            )
            .route(
                "/rooms/{room_id}/messages/{message_id}/reactions/{emoji}",
                web::delete().to(reaction::reaction_remove),
            )
            .route(
                "/rooms/{room_id}/messages/{message_id}/reactions",
                web::get().to(reaction::reaction_get),
            )
            // message search
            .route(
                "/rooms/{room_id}/messages/search",
                web::get().to(reaction::message_search),
            )
            // message edit history
            .route(
                "/rooms/{room_id}/messages/{message_id}/edit-history",
                web::get().to(draft_and_history::message_edit_history),
            )
            // mention notifications
            .route(
                "/me/mentions",
                web::get().to(draft_and_history::mention_list),
            )
            .route(
                "/me/mentions/read-all",
                web::post().to(draft_and_history::mention_read_all),
            )
            // room AI
            .route("/rooms/{room_id}/ai", web::get().to(ai::ai_list))
            .route("/rooms/{room_id}/ai", web::put().to(ai::ai_upsert))
            .route(
                "/rooms/{room_id}/ai/{model_id}",
                web::delete().to(ai::ai_delete),
            )
            // room category management
            .route(
                "/room-categories/{category_id}",
                web::patch().to(category::category_update),
            )
            .route(
                "/room-categories/{category_id}",
                web::delete().to(category::category_delete),
            )
            .route(
                "/me/notifications",
                web::get().to(notification::notification_list),
            )
            .route(
                "/me/notifications/{notification_id}/read",
                web::post().to(notification::notification_mark_read),
            )
            .route(
                "/me/notifications/read-all",
                web::post().to(notification::notification_mark_all_read),
            )
            .route(
                "/me/notifications/{notification_id}/archive",
                web::post().to(notification::notification_archive),
            ),
    );
}
