immosquare-slack 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/immosquare-slack/channel.rb +19 -6
- data/lib/immosquare-slack/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 382c2959d5d7d3869803f78d02a7247288a194045513777288caff5c2fa7abae
|
|
4
|
+
data.tar.gz: 403787e3740082733bb3966bd58bde6ccb45d4e3768e8f06027c1470e66872d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c93db1d79831bfbaab04b9e00b8fba3236c5e0e5bd040207498d573c05897575de36ef6ec38ecfadfc35481c4469e0a1fd8dce97c674d846ec57ee9606f3c78d
|
|
7
|
+
data.tar.gz: 233f3fe54d124c757f3c07369ca7a9d1e615d42b6c09d98d86e931d5dd98e22d7cd9abd9d042375d1a70b2c2aa9878ed79719ce11864a91ecf32e333b92d1c22
|
|
@@ -8,10 +8,17 @@ module ImmosquareSlack
|
|
|
8
8
|
|
|
9
9
|
##============================================================##
|
|
10
10
|
## Fetches the list of channels (public + private, including
|
|
11
|
-
## archived)
|
|
12
|
-
##
|
|
11
|
+
## archived), memoized per process for the lifetime of that
|
|
12
|
+
## process (a Puma worker or Sidekiq runs for hours/days).
|
|
13
|
+
##
|
|
14
|
+
## Piège : le cache ne reflète que l'état du workspace au
|
|
15
|
+
## premier appel. Un channel créé ou renommé ensuite n'y est
|
|
16
|
+
## pas. `force: true` vide le cache et refetch — à utiliser sur
|
|
17
|
+
## un miss de lookup pour distinguer un channel réellement
|
|
18
|
+
## absent d'un cache périmé avant tout fallback.
|
|
13
19
|
##============================================================##
|
|
14
|
-
def list_channels
|
|
20
|
+
def list_channels(force: false)
|
|
21
|
+
@list_channels = nil if force
|
|
15
22
|
@list_channels ||= begin
|
|
16
23
|
extra_params = {
|
|
17
24
|
:types => ["public_channel", "private_channel"].join(","),
|
|
@@ -40,7 +47,13 @@ module ImmosquareSlack
|
|
|
40
47
|
|
|
41
48
|
raise(ArgumentError, "channel_name is required (or set ImmosquareSlack.configuration.default_channel)") if channel_name.nil?
|
|
42
49
|
|
|
50
|
+
##============================================================##
|
|
51
|
+
## A miss can mean the channel really doesn't exist, or that
|
|
52
|
+
## the memoized list predates its creation. Retry once on a
|
|
53
|
+
## freshly fetched list before declaring it missing.
|
|
54
|
+
##============================================================##
|
|
43
55
|
channel_id = get_channel_id_by_name(channel_name)
|
|
56
|
+
channel_id = get_channel_id_by_name(channel_name, :force => true) if channel_id.nil?
|
|
44
57
|
|
|
45
58
|
if channel_id.nil?
|
|
46
59
|
text = "immosquare-slack missing channel *#{channel_name}*\nmessage:\n#{text}"
|
|
@@ -70,8 +83,8 @@ module ImmosquareSlack
|
|
|
70
83
|
## via the `is_general` flag because workspaces can rename
|
|
71
84
|
## their general channel.
|
|
72
85
|
##============================================================##
|
|
73
|
-
def get_channel_id_by_name(channel_name)
|
|
74
|
-
channels = list_channels
|
|
86
|
+
def get_channel_id_by_name(channel_name, force: false)
|
|
87
|
+
channels = list_channels(:force => force)
|
|
75
88
|
channel = channels.find do |c|
|
|
76
89
|
if channel_name == GENERAL_CHANNEL
|
|
77
90
|
c["is_general"]
|
|
@@ -79,7 +92,7 @@ module ImmosquareSlack
|
|
|
79
92
|
c["name"] == channel_name && c["is_archived"] == false
|
|
80
93
|
end
|
|
81
94
|
end
|
|
82
|
-
channel
|
|
95
|
+
channel&.[]("id")
|
|
83
96
|
end
|
|
84
97
|
|
|
85
98
|
##============================================================##
|