Cubit-Studios / Swarm-SlackNotify

A Helix Swarm module that provides enhanced Slack notifications for code reviews, focusing on direct communication with reviewers and review authors.
0 stars 0 forks source link

Unable to Receive Slack Notifications Post-Module Deployment #2

Open wanejen opened 1 week ago

wanejen commented 1 week ago

Hi,

I have followed the instructions you provided and configured the settings as suggested. However, I am still experiencing issues where Slack is not receiving any information, and I am not seeing any relevant output in the logs.

To assist with diagnosing the problem, I have attached screenshots of the current configurations for your reference. Additionally, here are some details about the environment:

The version of Swarm is "SWARM/2023.2/2458885 (2023/06/28)".

root@018cd8f9548d:/opt/perforce/swarm/module/SlackNotify/config# ls -l
total 12
-rw-r--r-- 1 root root 2036 Nov 21 08:16 module.config.php
-rw-r--r-- 1 root root  489 Nov 21 08:16 module.config.php.example
-rw-r--r-- 1 root root  526 Nov 21 08:28 slack-notify.config.php
root@018cd8f9548d:/opt/perforce/swarm/module/SlackNotify/config# cat slack-notify.config.php
<?php
/**
 * Example configuration for SlackNotify module
 * Copy this file to your Swarm config directory and adjust as needed
 */
return [
    'slack-notify' => [
        // OAuth token for your Slack app (REQUIRED)
        // I have confirmed that the token is correct.
        'token' => 'xoxb-xxx,

        // Channel for new review notifications (REQUIRED)
        'notify_channel' => 'swarm-notify',

        // Cache time for user mappings in seconds (OPTIONAL, defaults to 3600)
        'user_cache_ttl' => 3600,
    ]
];

root@018cd8f9548d:/opt/perforce/swarm/config# cat custom.modules.config.php
<?php
\Laminas\Loader\AutoloaderFactory::factory(
    array(
        'Laminas\Loader\StandardAutoloader' => array(
            'namespaces' => array(
                // ... other modules ...
                'SlackNotify'       => BASE_PATH . '/module/SlackNotify/src',
            )
        )
    )
);
return [
    // ... other modules ...
    'SlackNotify',
];

And I have already added enough permissions in Slack. image

Deams51 commented 1 week ago

I understand the confusion.

The config should be copied into the Swarm config file. For example: /opt/perforce/swarm/data/config.php

<?php
/* WARNING: The contents of this file is cached by Swarm. Changes to
 * it will not be picked up until the cached versions are removed.
 * See the documentation on the 'Swarm config cache'.
 */
return array(
    'environment' => array(
        'hostname' => 'xxxx.yyyyy.com',
    ),
    'p4' => array(
        'port' => 'ssl:0.1.2.3:1666',
        'user' => 'swarmUser',
        'password' => 'XXXXXXXXXXXX',
    ),
    'log' => array(
        'priority'  => 3, // 7 for max, defaults to 3
    ),
    'slack-notify' => array(
        'token' => 'xoxb-XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        'notify_channel' => 'swarm-channel-name',
    ),
);
wanejen commented 4 days ago

@Deams51 Thank you for your help. I have successfully received the notification after modifying the configuration. However, I found an issue during testing. I'm not sure if you are already aware, but it seems that there is an error when users submit comments under the review they created themselves (other people's comments are working fine).

2024-11-25T06:42:45+00:00 CRIT (2): TypeError: Argument 1 passed to SlackNotify\Service\SlackNotify::notifyNewComment() must be an instance of Reviews\Model\Review, null given, called in /opt/perforce/swarm/module/SlackNotify/src/Listener/ReviewActivity.php on line 131 and defined in /opt/perforce/swarm/module/SlackNotify/src/Service/SlackNotify.php:324
Stack trace:
#0 /opt/perforce/swarm/module/SlackNotify/src/Listener/ReviewActivity.php(131): SlackNotify\Service\SlackNotify->notifyNewComment()
#1 /opt/perforce/swarm/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): SlackNotify\Listener\ReviewActivity->handleReviewActivity()
#2 /opt/perforce/swarm/vendor/laminas/laminas-eventmanager/src/EventManager.php(170): Laminas\EventManager\EventManager->triggerListeners()
#3 /opt/perforce/swarm/module/Queue/src/Controller/IndexController.php(189): Laminas\EventManager\EventManager->triggerEvent()
#4 /opt/perforce/swarm/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(77): Queue\Controller\IndexController->workerAction()
#5 /opt/perforce/swarm/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\Controller\AbstractActionController->onDispatch()
#6 /opt/perforce/swarm/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners()
#7 /opt/perforce/swarm/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(103): Laminas\EventManager\EventManager->triggerEventUntil()
#8 /opt/perforce/swarm/vendor/laminas/laminas-mvc/src/DispatchListener.php(139): Laminas\Mvc\Controller\AbstractController->dispatch()
#9 /opt/perforce/swarm/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\DispatchListener->onDispatch()
#10 /opt/perforce/swarm/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners()
#11 /opt/perforce/swarm/vendor/laminas/laminas-mvc/src/Application.php(331): Laminas\EventManager\EventManager->triggerEventUntil()
#12 /opt/perforce/swarm/public/index.php(69): Laminas\Mvc\Application->run()
#13 {main}