From 47ae05d32953d0a7497cb32c7895c07fb5829313 Mon Sep 17 00:00:00 2001 From: Shashank Verma Date: Wed, 1 Nov 2023 13:51:28 +0530 Subject: [PATCH] controller: SuperAdminController: Fix creating of club Signed-off-by: Shashank Verma --- .../controller/SuperAdminController.kt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/mnnit/moticlubs/controller/SuperAdminController.kt b/src/main/kotlin/com/mnnit/moticlubs/controller/SuperAdminController.kt index 95351df..24b921d 100644 --- a/src/main/kotlin/com/mnnit/moticlubs/controller/SuperAdminController.kt +++ b/src/main/kotlin/com/mnnit/moticlubs/controller/SuperAdminController.kt @@ -1,10 +1,12 @@ package com.mnnit.moticlubs.controller import com.mnnit.moticlubs.dao.Admin +import com.mnnit.moticlubs.dao.Channel import com.mnnit.moticlubs.dao.Club import com.mnnit.moticlubs.dto.request.AddClubDTO import com.mnnit.moticlubs.dto.request.AssignAdminDTO import com.mnnit.moticlubs.service.AdminService +import com.mnnit.moticlubs.service.ChannelService import com.mnnit.moticlubs.service.ClubService import com.mnnit.moticlubs.utils.Constants.BASE_PATH import com.mnnit.moticlubs.utils.Constants.SUPER_ADMIN_ROUTE @@ -33,6 +35,7 @@ import reactor.core.publisher.Mono class SuperAdminController( private val pathAuthorization: PathAuthorization, private val clubService: ClubService, + private val channelService: ChannelService, private val adminService: AdminService, ) { @@ -65,7 +68,16 @@ class SuperAdminController( ), ) } - .invalidateStamp { ResponseStamp.CLUB } + .flatMap { club -> + LOGGER.info("addClub: creating general channel") + channelService.saveChannel( + Channel(cid = club.cid, name = "General", private = false), + ).map { club } + } + .invalidateStamp { + ResponseStamp.CHANNEL.invalidateStamp() + ResponseStamp.CLUB + } .wrapError() @DeleteMapping("/delete_club") @@ -76,7 +88,10 @@ class SuperAdminController( LOGGER.info("deleteClubByCid: cid: $clubId") clubService.deleteClubByCid(clubId) } - .invalidateStamp { ResponseStamp.CLUB } + .invalidateStamp { + ResponseStamp.CHANNEL.invalidateStamp() + ResponseStamp.CLUB + } .wrapError() @PostMapping("/add_admin")