Giter VIP home page Giter VIP logo

jolicode / secret-santa Goto Github PK

View Code? Open in Web Editor NEW
213.0 20.0 19.0 11.11 MB

:santa: The code behind Secret Santa, the holiday bot for Slack / Discord / Webex

Home Page: https://secret-santa.team/

License: MIT License

PHP 46.90% CSS 17.06% JavaScript 0.54% Shell 0.32% Twig 33.99% Dockerfile 1.18%
symfony secret-santa happyness symfony-flex discord-bot slack-bot discord slack slack-blockkit hacktoberfest

secret-santa's Introduction

Secret Santa app

Just go to https://secret-santa.team/ and have fun.

Code source is under MIT License.

Running the application locally

Requirements

A Docker environment is provided and requires you to have these tools available:

  • Docker
  • Bash
  • PHP >= 8.1
  • Castor

Castor

Once castor is installed, in order to improve your usage of castor scripts, you can install console autocompletion script.

If you are using bash:

castor completion | sudo tee /etc/bash_completion.d/castor

If you are using something else, please refer to your shell documentation. You may need to use castor completion > /to/somewhere.

Castor supports completion for bash, zsh & fish shells.

Docker environment

The Docker infrastructure provides a web stack with:

  • NGINX
  • Redis
  • PHP
  • Traefik
  • A container with some tooling:
    • Composer
    • Node
    • Yarn / NPM

Domain configuration (first time only)

Before running the application for the first time, ensure your domain names point the IP of your Docker daemon by editing your /etc/hosts file.

This IP is probably 127.0.0.1 unless you run Docker in a special VM (docker-machine, dinghy, etc).

Note: The router binds port 80 and 443, that's why it will work with 127.0.0.1

echo '127.0.0.1 secret-santa.test' | sudo tee -a /etc/hosts

Using dinghy? Run dinghy ip to get the IP of the VM.

Env vars configuration (first time only)

We rely on some env variables to configure how to communicate with various API's and Redis.

Copy the content of the file .env into a new .env.local (which will be ignored by git) and fill the missing vars with correct values.

Starting the stack

Launch the stack by running this command:

castor start

Note

the first start of the stack should take a few minutes.

The site is now accessible at the hostnames your have configured over HTTPS (you may need to accept self-signed SSL certificate if you do not have mkcert installed on your computer - see below).

SSL certificates

This stack no longer embeds self-signed SSL certificates. Instead they will be generated the first time you start the infrastructure (castor start) or if you run castor infra:generate-certificates. So HTTPS will work out of the box.

If you have mkcert installed on your computer, it will be used to generate locally trusted certificates. See mkcert documentation to understand how to install it. Do not forget to install CA root from mkcert by running mkcert -install.

If you don't have mkcert, then self-signed certificates will instead be generated with openssl. You can configure infrastructure/docker/services/router/openssl.cnf to tweak certificates.

You can run castor infra:generate-certificates --force to recreate new certificates if some were already generated. Remember to restart the infrastructure to make use of the new certificates with castor up or castor start.

Builder

Having some composer, yarn or other modifications to make on the project? Start the builder which will give you access to a container with all these tools available:

castor builder

Other tasks

Checkout castor to have the list of available tasks.

secret-santa's People

Contributors

alexzerah avatar baptadn avatar damienalexandre avatar dependabot[bot] avatar dunglas avatar hedicguibert avatar korbeil avatar lilja avatar lyrixx avatar m8051 avatar mookman288 avatar nclm avatar nispeon avatar pgrimaud avatar pyrech avatar ternel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

secret-santa's Issues

Suggestion: display only ONE name in the "You have been chosen to gift X" message.

Hi there!

We have been using Secret Santa for a couple of years now, and this year we encountered a "bug" or maybe more of a user experience failure:

The problem

This year, our Secret Santa admin received 2 gift instead of one, and someone did't get a present.

But it wasn't an algorithm failure, here's what happened:

  • Once all is set, each player gets a You've been chosen to gift X message.
  • The X being the tag name of the designated target.
  • But this message also contain another name (that is automatically highlighted by Slack as well): the admin's tag name.
  • One player simply identified the second name as their Secret Santa target.
  • So their real designated target didn't get anything*.

In an environment saturated by notifications of all kind, and with just a little bit of inattention, I think anyone could have make the same mistake.
The very nature of secret Santa made it impossible for us to identify there had been a confusion before the due date.

My suggestion

Maybe, for this critical** message, don't mention the admin's name at all.
Only display the target's name to prevent any confusion.



Did anyone else experienced that problem?
What do you think?

We would like to thank you all for that very important piece of software. πŸŽ…πŸŽ„β˜ƒοΈ


*: And yet they deserved it! They've been a very good person all year. 😒
**: Yeah... we're very serious about Christmas 😁

Increase Slack API calls timeout

A lot of Slack API calls are failing these days. It looks like it's related to a network timeout :

cURL error 28: Operation timed out after 2001 milliseconds with 0 bytes received

We should probably make the timeout greater than 2 seconds (5 or 10s should be fine)

Bust CSS when it's updated

I got a report from a user, the old CSS was in it's cache and when displaying the Hall of fame everything was broken.

We don't update CSS that often so no need to make it automatic.

Allow to exclude some combinations of users

Sometimes Secret Santa is run in organisations where some people should not give each other a gift (think a family where a couple don't want to be assigned one to another) but still want to be part of the gift exchange.

We could allow users to select "forbidden assignations", when all the users are selected.

It should not be a preview of the draw, just a list of rules, to keep the magic / the secret!

Secret message formatting

Great Slack app!

I think the formatting of the message sent to the participants can be improved though. As it is now, it's not immediately evident to see who you have been matched with, being just a little mention in a sentence. Especially too because the visual focus is on the admin message, not on the selected username.


The current formatting looks like this:

before


It could for instance be made like this instead:

after


Markup:

Hi!

You have been chosen to be part of a Secret Santa!
Someone has been chosen to get you a gift.

> *And you have been chosen to gift:*
> :gift: *@username*

Here is a message from the Secret Santa admin:

` ` `
TEST
` ` `
_– Your Secret Santa admin, @admin._

(with no space between the back ticks)


There's still matter to improve, but it's a quick fix that can make the app so much more clear :)

Send spoiling procedure by email

Some organization uses the Slack free plan and thus have a limited message history. The secret santa admin can then loose the message to retrieve the secret repartition.

We could propose to also send the spoiling method by email at the end of the process. This obviously requires to setup a mail platform.

Send the summary automatically to the Secret Santa admin?

We receive a lot of support requests for Secret Santa summary access after the fact,
and as we don't want to store anything we can't help most of those users.

Maybe it's possible to send the summary file to the admin, maybe with a un-readable format (rot13?), and a link to a page where we un-code the content.

We need to check if SlackBot can send files.

Rename the app and change the namespace

Namespace:

  • Current namespace is Joli\SlackSecretSanta.
  • Should be Joli\SecretSanta, or even JoliCode\SecretSanta

Repo:

  • Current repo is jolicode/slack-secret-santa
  • Should be jolicode/secret-santa

To be done later.

Date and time of sending

It would be nice to have an option to select the date and time when the messages will be sent to everyone. I'd love to be able to set up my Secret Santa now, and have it run on Friday at 6 pm for instance. So that it can be planned for a company event without having to go back behind the computer and set up everything at the last minute.

Better user selection workflow

After allowing our app to access slack data, we have to check all the users participating to the secret santa. It could be nice to have a selection by channel or something like that to ease this step.

Add support for Microsoft Team

Provide a new deployment of Slack Secret Santa called "Team Secret Santa", working with Microsoft Team: https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/apps/apps-overview

Creation process

To be done / tested

  • Test if everything is OK with the desktop app

Add support for Atlassian Stride

Atlassian released https://www.stride.com/ - the replacement for HipChat and a new way for teams to work and communicate. There is apps on it so we should be able to make Secret Santa compatible!

So far there is 25 apps: https://marketplace.atlassian.com/addons/app/stride?_ga=2.168561697.1487835320.1526475674-311972830.1526475674

ping @yulz ❀️

Fix the Content Security Policy to allow avatars display and JavaScript

Avatars are not displayed anymore:

image

Our pages send this header: Content-Security-Policy: default-src 'self'; base-uri 'self'; so the avatars gets blocked:

image

Also, inline JavaScript is not executed:

Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-SYgPl6GxmNtUIiPe4ASGGixmj9g/tOP622WecLQi6Qo='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

So... Nothing works right now.

Broken message due to "<" char

Just set it up for my company! Pro tip for anyone that wants to do this: be careful about what you include in the markdown writeup. My message included "<=" in the budget description, which made something barf and cut off most of my message. Otherwise, worked like a charm

We should remove the strip_tag protection. As the message is sent in a markdown, we can safely remove this protection. We must only forbid the use of "```"

Warning on the UserExtractor

Seen in the logs:

2019-11-15T12:49:07+01:00 [:error] [pid 1169:tid 139881523087104] [client 46.252.181.103:37412] FastCGI: server "/var/www/php5-fpm/php5.external" stderr: PHP message: [2019-11-15 11:49:05] php.WARNING: Warning: Invalid argument supplied for foreach() {"exception":"[object] (ErrorException(code: 0): Warning: Invalid argument supplied for foreach() at /home/bas/app_2e11a7d1-37ca-4bd1-8b51-083011a69f18/src/Slack/UserExtractor.php:108)"} [], referer: https://secret-santa.team/

Better retry workflow

We need to improve the retry workflow.

A quick win would be to at least add a percentage of messages sent on this page.
Something that would be nice too would be to launch the retry automatically.

The best workflow I can think of ATM is:

  • on submit, post the form to sav in session (as it's done now)
  • redirect to simple page that will trigger the sending of the messages in Ajax
  • display a real-time percentage on this page
  • retry automatically when the server answer a timeout and update the percentage
  • redirect to the finish page

Improve the logs for network errors

When the API is down or does not respond in a timely manner, we may not see any log in our Clever Cloud hosting.

Let's fix that. And maybe use Sentry?

Make the stats page work when there is no data in Redis

When booting the app without data, we get this error:

 FastCGI: server "/var/www/php5-fpm/php5.external" stderr: PHP message: [2018-10-05 16:37:42] request.CRITICAL: Uncaught PHP Exception Predis\\Response\\ServerException: "ERR wrong number of arguments for 'mget' command" at /home/bas/app_2e11a7d1-37ca-4bd1-8b51-083011a69f18/vendor/predis/predis/src/Client.php line 370 {"exception":"[object] (Predis\\\\Response\\\\ServerException(code: 0): ERR wrong number of arguments for 'mget' command at //vendor/predis/predis/src/Client.php:370)"} []

Slack permission "email" is requested for nothing

We have a long lasting issue with Slack Apps requesting the email scope, even if we dont request it (we request users:read). Last February we got this answer from them:

Hi again Damien,
I am sorry to report that we are not able to remove the scoped email access that your app currently has been granted due to the older users:read scope.
We do not have a timeline on when we will be adjusting this from our side, and as far as I know, the only workaround is to create a new app (losing currently installations if you fully delete that app) and start fresh with a newly created app that won't have the same issues.
Apologies for the bad news here. Let me know if you have any other thoughts/questions.
Thanks,
xxx

So just because the app was created a long time ago, the email address is always asked for and this can't be removed.

More than a year after, I tried the suggestion to create a new app. Here is the results:

Actual application

image

New unpublished application

image

Conclusions

If we want to get rid of the View email addresses of people on your workspace permission, our only solution is to create a brand new application on Slack Apps, and go through the complete publication procedure.

Avoid Heroku router and PHP timeout

  • Heroku router stop everything at 30s and there is no way to take back control of the response
  • A very large secret santa can send hundreds of Slack API requests

We have to make sure users are never left with in incomplete "Secret Santa" where only a bunch of users are notified. We have to:

  • Add a low timeout on Slack API requests (1/2 seconds)
  • Make sure the PHP script does stop itself nicely at ~25 seconds
  • Display the proper "sorry" message and allow to download the list of users to notify manually (maybe a "retry" button could be used to send the remaining users?)

Wishlist for Secret Santa.

A public wishlist that everyone can see by manually checking with the bot.
Notify the secret santa when wishes are added by respective person for secret santa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.