Skip to content

Commit

Permalink
[#140] feat: 회원가입 시 회원 수 슬랙 알림 발송
Browse files Browse the repository at this point in the history
  • Loading branch information
JuHyun419 committed Sep 10, 2022
1 parent ae2adcf commit e6aef3f
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.yapp.web2.exception.custom.ExistNameException
import com.yapp.web2.exception.custom.FolderNotRootException
import com.yapp.web2.exception.custom.ImageNotFoundException
import com.yapp.web2.exception.custom.PasswordMismatchException
import com.yapp.web2.infra.slack.SlackService
import com.yapp.web2.security.jwt.JwtProvider
import com.yapp.web2.security.jwt.TokenDto
import com.yapp.web2.util.Message
Expand All @@ -34,7 +35,8 @@ class AccountService(
private val jwtProvider: JwtProvider,
private val s3Client: S3Client,
private val passwordEncoder: PasswordEncoder,
private val mailSender: JavaMailSender
private val mailSender: JavaMailSender,
private val slackApi: SlackService
) {

@Value("\${extension.version}")
Expand Down Expand Up @@ -77,8 +79,16 @@ class AccountService(
isRegistered = false
val newAccount = createUser(account)
folderService.createDefaultFolder(account)

val userCountMessage = """
${newAccount.id}: ${newAccount.name} 님이 회원가입을 진행하였습니다. 현재 회원 수: *`${accountRepository.count()}`*
""".trimIndent()

slackApi.sendSlackAlarmToVerbose(userCountMessage)

newAccount
}

else -> {
log.info("소셜로그인 => ${account.email} 계정이 이미 존재합니다.")
existAccount.fcmToken = account2.fcmToken
Expand All @@ -101,6 +111,12 @@ class AccountService(

log.info("${newAccount.email} account signUp succeed")

val userCountMessage = """
${newAccount.id}: ${newAccount.name} 님이 회원가입을 진행하였습니다. 현재 회원 수: *`${accountRepository.count()}`*
""".trimIndent()

slackApi.sendSlackAlarmToVerbose(userCountMessage)

return Account.AccountLoginSuccess(jwtProvider.createToken(newAccount), newAccount, false)
}

Expand Down Expand Up @@ -200,7 +216,7 @@ class AccountService(
val rootFolder = folderService.findByFolderId(folderId)

if (rootFolder.rootFolderId != folderId) throw FolderNotRootException()
if(!rootFolder.isInviteState()) throw RuntimeException("보관함이 초대잠금상태입니다. 가입할 수 없습니다.")
if (!rootFolder.isInviteState()) throw RuntimeException("보관함이 초대잠금상태입니다. 가입할 수 없습니다.")

val accountFolder = AccountFolder(account, rootFolder)
accountFolder.changeAuthority(Authority.INVITEE)
Expand Down

0 comments on commit e6aef3f

Please sign in to comment.