override fun sendBuildRelatedNotification()

in src/main/kotlin/jetbrains/buildServer/notification/slackNotifier/notification/SlackNotifier.kt [338:378]


    override fun sendBuildRelatedNotification(
        message: String, runningBuild: SRunningBuild, parameters: MutableMap<String, String>
    ) {
        val buildType = runningBuild.buildType

        if (buildType == null) {
            logger.warn("Could not find a build configuration for ${LogUtil.describe(runningBuild)}")
            return
        }

        val project = buildType.project

        val connectionDescriptor = findConnectionForAdHocNotification(project, parameters)

        checkExternalDomainsInMessage(runningBuild, message, connectionDescriptor)

        val token = getToken(project, connectionDescriptor.id)
            ?: throw ServiceMessageNotificationException(
                "No token for connection with id '${connectionDescriptor.id}'" +
                        " in project with external id '${project.externalId}' was found"
            )

        val sendTo = parameters["sendTo"]
            ?: throw ServiceMessageNotificationException("'sendTo' argument was not specified for message $message, build ID ${runningBuild.buildId}")

        val processedMessagePayload = serviceMessageMessageBuilder.buildRelatedNotification(
            runningBuild,
            message
        )

        val lock: Lock = myMessageLimitLocks.get(runningBuild.buildId) // avoid race in notifications count logic
        lock.lock()

        try {
            checkAdHocNotificationLimit(runningBuild, connectionDescriptor)
        } finally {
            lock.unlock()
        }

        sendMessage(processedMessagePayload, sendTo, token)
    }