]> git.sesse.net Git - skvidarsync/commitdiff
Support marking with orange.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 4 Mar 2024 14:07:25 +0000 (15:07 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 4 Mar 2024 14:11:44 +0000 (15:11 +0100)
bin/sync.pl

index 740d38f117e9cd1487be44278a6425222bdc37ab..23c56274d35d57d123e2062cf03bd1972021673e 100644 (file)
@@ -32,6 +32,12 @@ my %rgb = (
                blue => 0,
                alpha => 1
        },
+       orange => {
+               red => 0xf9 / 255.0,
+               green => 0xcb / 255.0,
+               blue => 0x9c / 255.0,
+               alpha => 1
+       },
        blue => {
                red => 0,
                green => 1,
@@ -344,7 +350,7 @@ sub best_name_for_log {
 sub create_reaction_log {
        my ($dbh, $invitation_ts, $slack_userid_to_real_name, $slack_userid_to_slack_name) = @_;
 
-       my $q = $dbh->prepare('select userid,event_type,reaction,to_char(event_ts,\'YYYY-mm-dd HH24:MI\') as event_ts from ( select distinct on (channel,ts,userid,reaction) userid,event_type,reaction,timestamptz \'1970-01-01 utc\' + event_ts::float * interval \'1 second\' as event_ts from reaction_log where channel=? and ts=? and reaction in (\'heart\',\'open_mouth\',\'blue_heart\') order by channel,ts,userid,reaction,event_ts desc ) t1 where event_ts > current_timestamp - interval \'8 hours\' order by event_ts desc limit 50');
+       my $q = $dbh->prepare('select userid,event_type,reaction,to_char(event_ts,\'YYYY-mm-dd HH24:MI\') as event_ts from ( select distinct on (channel,ts,userid,reaction) userid,event_type,reaction,timestamptz \'1970-01-01 utc\' + event_ts::float * interval \'1 second\' as event_ts from reaction_log where channel=? and ts=? and reaction in (\'heart\',\'open_mouth\',\'blue_heart\',\'orange_heart\') order by channel,ts,userid,reaction,event_ts desc ) t1 where event_ts > current_timestamp - interval \'8 hours\' order by event_ts desc limit 50');
        $q->execute($config::invitation_channel, $invitation_ts);
        my @recent_changes = ();
        while (my $ref = $q->fetchrow_hashref) {
@@ -358,6 +364,8 @@ sub create_reaction_log {
                        $msg .= '๐Ÿ˜ฎ';
                } elsif ($ref->{'reaction'} eq 'blue_heart') {
                        $msg .= '๐Ÿ’™';
+               } elsif ($ref->{'reaction'} eq 'orange_heart') {
+                       $msg .= '๐Ÿงก';
                } else {
                        $msg .= 'โค๏ธ';
                }
@@ -544,7 +552,7 @@ sub run {
        }
 
        # Find everyone who are marked as attending on Slack (via reactions).
-       $q = $dbh->prepare('SELECT DISTINCT userid,reaction FROM current_reactions WHERE channel=? AND ts=? AND reaction IN (\'heart\', \'open_mouth\', \'blue_heart\')');
+       $q = $dbh->prepare('SELECT DISTINCT userid,reaction FROM current_reactions WHERE channel=? AND ts=? AND reaction IN (\'heart\', \'open_mouth\', \'blue_heart\', \'orange_heart\')');
        $q->execute($config::invitation_channel, $invitation_ts);
        my @attending_userids = ();
        my %colors = ();
@@ -553,12 +561,17 @@ sub run {
                my $userid = $ref->{'userid'};
                push @attending_userids, $userid;
                if ($ref->{'reaction'} eq 'blue_heart') {
-                       if (exists($colors{$userid}) && $colors{$userid} eq 'yellow') {
+                       if (exists($colors{$userid}) && $colors{$userid} ne 'blue') {
                                $double{$userid} = 1;
                        }
                        $colors{$userid} = 'blue';
+               } elsif ($ref->{'reaction'} eq 'orange_heart') {
+                       if (exists($colors{$userid}) && $colors{$userid} ne 'orange') {
+                               $double{$userid} = 1;
+                       }
+                       $colors{$userid} = 'orange';
                } else {
-                       if (exists($colors{$userid}) && $colors{$userid} eq 'blue') {
+                       if (exists($colors{$userid}) && $colors{$userid} ne 'yellow') {
                                $double{$userid} = 1;
                        }
                        $colors{$userid} = 'yellow';