Exemplo n.º 1
0
 private function postPublicRelation($channelId)
 {
     if (SlackChannelPublic::find($channelId) == null) {
         SlackChannelPublic::create(['channel_id' => $channelId]);
         return redirect()->back()->with('success', 'New public slack relation has been created');
     }
     return redirect()->back()->with('error', 'This relation already exists');
 }
Exemplo n.º 2
0
 public function testChannel()
 {
     $permission = SlackChannelPublic::where('channel_id', '=', 'C1Z920QKC')->first();
     $artifact = SlackChannel::find('C1Z920QKC');
     $this->assertEquals($artifact, $permission->channel);
 }
Exemplo n.º 3
0
 /**
  * Determine all channels in which an user is allowed to be
  *
  * @param SlackUser $slackUser
  * @param boolean $private Determine if channels should be private (group) or public (channel)
  * @return array
  */
 protected function allowedChannels(SlackUser $slackUser, $private)
 {
     $channels = [];
     $rows = User::join('slack_channel_users', 'slack_channel_users.user_id', '=', 'users.id')->join('slack_channels', 'slack_channel_users.channel_id', '=', 'slack_channels.id')->select('channel_id')->where('users.id', $slackUser->user_id)->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->union(DB::table('role_user')->join('slack_channel_roles', 'slack_channel_roles.role_id', '=', 'role_user.role_id')->join('slack_channels', 'slack_channel_roles.channel_id', '=', 'slack_channels.id')->where('role_user.user_id', $slackUser->user_id)->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->select('channel_id'))->union(ApiKey::join('account_api_key_info_characters', 'account_api_key_info_characters.keyID', '=', 'eve_api_keys.key_id')->join('slack_channel_corporations', 'slack_channel_corporations.corporation_id', '=', 'account_api_key_info_characters.corporationID')->join('slack_channels', 'slack_channel_corporations.channel_id', '=', 'slack_channels.id')->where('eve_api_keys.user_id', $slackUser->user_id)->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->select('channel_id'))->union(CharacterSheet::join('slack_channel_alliances', 'slack_channel_alliances.alliance_id', '=', 'character_character_sheets.allianceID')->join('slack_channels', 'slack_channel_alliances.channel_id', '=', 'slack_channels.id')->join('account_api_key_info_characters', 'account_api_key_info_characters.characterID', '=', 'character_character_sheets.characterID')->join('eve_api_keys', 'eve_api_keys.key_id', '=', 'account_api_key_info_characters.keyID')->where('eve_api_keys.user_id', $slackUser->user_id)->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->select('channel_id'))->union(SlackChannelPublic::join('slack_channels', 'slack_channel_public.channel_id', '=', 'slack_channels.id')->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->select('channel_id'))->get();
     foreach ($rows as $row) {
         $channels[] = $row->channel_id;
     }
     return $channels;
 }