Class: Legion::Extensions::MicrosoftTeams::Actor::CacheSync

Inherits:
Actors::Every
  • Object
show all
Defined in:
lib/legion/extensions/microsoft_teams/actors/cache_sync.rb

Constant Summary collapse

SYNC_INTERVAL =

5 minutes

300

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ CacheSync

Returns a new instance of CacheSync.



10
11
12
13
14
15
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 10

def initialize(**opts)
  return unless enabled?

  @last_sync_time = nil
  super
end

Instance Method Details

#argsObject



31
32
33
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 31

def args
  { since: @last_sync_time, skip_bots: true }
end

#check_subtask?Boolean

Returns:

  • (Boolean)


22
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 22

def check_subtask?  = false

#enabled?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 25

def enabled?
  # TODO: local cache has no chat type metadata — cannot filter out channel
  #       messages. Disabled until cache records include chatType.
  false
end

#generate_task?Boolean

Returns:

  • (Boolean)


23
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 23

def generate_task?  = false

#manualObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 35

def manual
  result = runner_class.send(runner_function, since: @last_sync_time, skip_bots: true)
  if result.is_a?(Hash) && result[:result]
    latest = result[:result][:latest_time]
    @last_sync_time = latest if latest
    stored = result[:result][:stored] || 0
    log.info("CacheSync: ingested #{stored} new Teams messages") if stored.positive?
  end
rescue StandardError => e
  log.error("CacheSync: #{e.message}")
end

#run_now?Boolean

Returns:

  • (Boolean)


20
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 20

def run_now?        = false

#runner_classObject



17
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 17

def runner_class    = Legion::Extensions::MicrosoftTeams::Runners::CacheIngest

#runner_functionObject



18
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 18

def runner_function = 'ingest_cache'

#timeObject



19
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 19

def time            = SYNC_INTERVAL

#use_runner?Boolean

Returns:

  • (Boolean)


21
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 21

def use_runner?     = false