Module: Legion::Extensions::MicrosoftTeams::Runners::LocalCache

Includes:
Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/microsoft_teams/runners/local_cache.rb

Instance Method Summary collapse

Instance Method Details

#extract_local_messages(db_path: nil, since: nil, channels: nil, senders: nil, skip_bots: true) ⇒ Object

Extract messages from the local Teams LevelDB cache. Works offline without Graph API credentials.



12
13
14
15
16
17
18
19
# File 'lib/legion/extensions/microsoft_teams/runners/local_cache.rb', line 12

def extract_local_messages(db_path: nil, since: nil, channels: nil, senders: nil, skip_bots: true, **)
  opts = {}
  opts[:db_path] = db_path if db_path
  extractor = MicrosoftTeams::LocalCache::Extractor.new(**opts)
  messages = extractor.extract(since: since, channels: channels,
                               senders: senders, skip_bots: skip_bots)
  { result: messages.map { |m| message_to_hash(m) } }
end

#local_cache_available?(db_path: nil) ⇒ Boolean

Check if the local Teams cache is available.

Returns:

  • (Boolean)


22
23
24
25
26
27
# File 'lib/legion/extensions/microsoft_teams/runners/local_cache.rb', line 22

def local_cache_available?(db_path: nil, **)
  opts = {}
  opts[:db_path] = db_path if db_path
  extractor = MicrosoftTeams::LocalCache::Extractor.new(**opts)
  { result: extractor.available? }
end

#local_cache_stats(db_path: nil) ⇒ Object

Get stats about the local Teams cache without extracting messages.



30
31
32
33
34
35
# File 'lib/legion/extensions/microsoft_teams/runners/local_cache.rb', line 30

def local_cache_stats(db_path: nil, **)
  opts = {}
  opts[:db_path] = db_path if db_path
  extractor = MicrosoftTeams::LocalCache::Extractor.new(**opts)
  { result: extractor.stats }
end