From 671a294bd9bd472399fd0dae3fc93a5159ebfea3 Mon Sep 17 00:00:00 2001 From: Vagner do Carmo Date: Sat, 1 Aug 2015 23:54:30 -0300 Subject: [PATCH] Allowing by env variable to hide users status message on homepage. --- .env.example | 9 ++++++++- app/Http/Controllers/IndexController.php | 5 ++++- readme.md | 12 +++++++++++- resources/views/slack/index.blade.php | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index f0267e2..5f1ceb7 100644 --- a/.env.example +++ b/.env.example @@ -9,9 +9,12 @@ CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync -# Your Team Slack Token +# (REQUIRED) Your Team Slack Token SLACK_TOKEN=YOUR-SLACK-TOKEN-WITH-ADMIN-PRIVILEGIES +# (OPTIONAL) Indicates if should show the slack status message with users ative/total registered. +SLACK_STATUS_ENABLED=true + ##################################################################################### ## Language Detector Configurations ## ## see https://github.com/vluzrmos/laravel-language-detector ## @@ -19,11 +22,15 @@ SLACK_TOKEN=YOUR-SLACK-TOKEN-WITH-ADMIN-PRIVILEGIES #Indicates whenever should autodetect the language (it could be removed) LANG_DETECTOR_AUTODETECT=true + #The driver to use, default is browser LANG_DETECTOR_DRIVER="browser" + #The segment to use in uri or subdomain driver, default 0 (it could be removed) LANG_DETECTOR_SEGMENT=0 + #A comma-separated list of available languages on application LANG_DETECTOR_LANGUAGES="en,pt_BR" + #To aliase the language use the notation ":", "=", ":=" or "=>" to separate the alias and its value. # LANG_DETECTOR_LANGUAGES="en, en-us:en, pt-br:pt_BR" diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index 90bfaca..efdac57 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -39,10 +39,13 @@ public function __construct(Cache $cache, SlackStatusService $slack) public function getIndex() { $data = [ - 'totals' => $this->slack->getUsersStatus(), 'team' => $this->slack->getTeamInfo(), ]; + if (env('SLACK_STATUS_ENABLED', true)) { + $data['totals'] = $this->slack->getUsersStatus(); + } + return view('slack.index', $data); } diff --git a/readme.md b/readme.md index 7b573cd..70cb683 100644 --- a/readme.md +++ b/readme.md @@ -29,6 +29,7 @@ Change the SLACK_TOKEN to the token of your user on slack team, wit ## Run +## Queue Start the queue listener: ```bash @@ -44,6 +45,8 @@ php artisan queue:listen --timeout=240 1>> /dev/null 2>&1 & @reboot php /path/to/that/project/artisan queue:listen --timeout=240 1>> /dev/null 2>&1 ``` +### Scheduled Tasks (Optional) + You may also need to add that command to your cronjob, that will update the users status on every minute: ```bash @@ -51,7 +54,14 @@ You may also need to add that command to your cronjob, that will update the user ``` That will make your queue run in background and ignoring error messages. - + +**Note:** If you do not want to use that feature, you just need to set the environment +variable `SLACK_STATUS_ENABLED` to `false` on your `.env` file, that will hide the message +about users active (online/total) of your team on the homepage: + + SLACK_STATUS_ENABLED=false + +### HTTP Server Start the http server: diff --git a/resources/views/slack/index.blade.php b/resources/views/slack/index.blade.php index 8f54981..14f2269 100644 --- a/resources/views/slack/index.blade.php +++ b/resources/views/slack/index.blade.php @@ -11,9 +11,11 @@ {!! trans('slackin.join', ['team' => $team['name']]) !!} + @if(isset($totals, $totals['active'], $totals['total']))
{!! trans_choice('slackin.users_online', $totals['active'], $totals) !!}
+ @endif