Sha256: 862e57f7af81936c9c6fcd5e7ba64ca826b3824b1b047586d610d3b37043620d

Contents?: true

Size: 810 Bytes

Versions: 3

Compression:

Stored size: 810 Bytes

Contents

class SlackSmartBot
  def update_vacations(vacation=nil)
    require 'yaml'
    unless vacation.nil?
      get_vacations()
      @vacations.merge!(vacation)
    end
    user = Thread.current[:user]
    team_id_user = Thread.current[:team_id_user]
    #create folder if doesn't exist
    FileUtils.mkdir_p(File.join(config.path, "vacations/#{user.team_id}")) unless File.exist?(File.join(config.path, "vacations/#{user.team_id}"))
    vacations_file = File.join(config.path, "vacations/#{user.team_id}", "v_#{user.name}.yaml")

    File.open(vacations_file, 'w') {|file|
      file.flock(File::LOCK_EX)
      file.write(Utils::Encryption.encrypt(@vacations[team_id_user].to_yaml, config))
      file.flock(File::LOCK_UN)
    }
    @datetime_vacations_file[vacations_file] = File.mtime(vacations_file)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.15.25 lib/slack/smart-bot/utils/update_vacations.rb
slack-smart-bot-1.15.1 lib/slack/smart-bot/utils/update_vacations.rb
slack-smart-bot-1.15.0 lib/slack/smart-bot/utils/update_vacations.rb