# Babble: 管理者は「グループ所有者」のみ表示に設定されたグループを確認できない

**URL:** https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413
**Category:** Support
**Created:** [2019 年 7 月 19 日午後 12:57 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413 "2019-07-19T12:57:44Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [2019 年 7 月 19 日午後 12:57 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/1 "2019-07-19T12:57:45Z")

</div>

私が運営しているフォーラムでこの問題が発生しました。再現手順は以下の通りです：

1. 管理者として新しいグループを作成
2. 表示設定を「グループオーナー」に設定
3. グループを作成
4. `/g` に戻る
5. グループが表示されない

コンソールで `Group.find_by(name: <name>)` を実行して確認すると、正しく返却されます。表示設定を「グループオーナーとスタッフ」に変更すると、正しく表示されます。

これは意図的な仕様でない限り、この表示レベルではモデレーターではなくとも管理者がグループを表示できると想定されます。

この挙動には、昨日 2.4.0.beta2 へのアップグレードを行うまで気づいていませんでした。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019 年 7 月 19 日午後 1:02 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/2 "2019-07-19T13:02:38Z")

</div>

再読み込みは役立ちますか？

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [2019 年 7 月 19 日午後 1:03 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/3 "2019-07-19T13:03:20Z")

</div>

いいえ、JSON エンドポイントを呼び出しても、グループは管理者として表示されません。

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [2019 年 7 月 19 日午後 1:41 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/5 "2019-07-19T13:41:09Z")

</div>

最近これに取り組んだので、確認します。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019 年 7 月 19 日午後 1:51 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/6 "2019-07-19T13:51:44Z")

</div>

そうね。あなたが見過ごすようなことではなかったと思うけど、それが私には唯一の手段だったの。😉

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [2019 年 7 月 19 日午後 3:48 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/7 "2019-07-19T15:48:58Z")

</div>

@justin さん、この問題は再現できません。ローカル環境と DO ホスティングインスタンスの両方で試しましたが、2 つの異なる管理者アカウントからグループを作成しようとしました。いずれの場合も、管理者はすべてのグループを閲覧できています。

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [2019 年 7 月 19 日午後 3:56 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/8 "2019-07-19T15:56:00Z")

</div>

おかしいな。クリーンインストールで試してみないと。手持ちの本番インスタンスでは確実に再現できます。アップデートして、そこから進めましょう。

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [2019 年 7 月 23 日午後 8:43 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/9 "2019-07-23T20:43:26Z")

</div>

新規インストールで試しましたが、@pmusaraj 様と同じ結果になりました。おそらく、使用中のプラグインが原因ではないかと推測します。原因が判明次第、改めてご報告いたします。

---

<div class="post-metadata">

### Author: ![outofthebox](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outofthebox/32/83708_2.png) [@outofthebox](https://meta.discourse.org/u/outofthebox)
#### Post date: [2019 年 8 月 6 日午後 5:48 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/10 "2019-08-06T17:48:15Z")

</div>

私もこの問題に遭遇しました…

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2019 年 8 月 8 日午前 2:59 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/11 "2019-08-08T02:59:16Z")

</div>

プラグインも使っていますか？どのプラグインですか（Discourse が作成・配布していないものに焦点を当てて）…それとも、これは新しい回帰現象だと言っているのですか、@justin？

---

<div class="post-metadata">

### Author: ![outofthebox](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outofthebox/32/83708_2.png) [@outofthebox](https://meta.discourse.org/u/outofthebox)
#### Post date: [2019 年 8 月 8 日午後 12:05 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/12 "2019-08-08T12:05:40Z")

</div>

こんにちは。グループの可視性を「グループオーナー」から「グループオーナー、メンバー」に変更したら、再び表示されるようになりました。「グループオーナー」に限定された場合のグループ設定に関するコードに何か不具合があるのでしょうか？

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [2019 年 8 月 8 日午後 8:45 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/13 "2019-08-08T20:45:01Z")

</div>

@outofthebox 偶然でも、Babble チャットプラグインがインストールされていましたか？そのプラグインをインスタンスから削除した後、それが原因で問題が再発したようです。そのプラグインをアンインストールして再構築したところ、グループの可視性が復元されました。

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [2019 年 8 月 8 日午後 8:59 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/14 "2019-08-08T20:59:05Z")

</div>

@justin 素晴らしい発見ですね。Babble のソースコードを簡単に確認したところ、コアのグループに関する私の更新と競合しているようです。Babble は `visibility_level: 4` に対してハードコードされたルールを追加しており、これが現在コア内の `owners` グループと競合しています。

> <https://github.com/gdpelican/babble/blob/b5500411a6d322478426e9e86eadbfdb51924a36/app/models/group.rb#L4>

@gdpelican さんがお時間のある時に確認していただけると幸いです。

---

<div class="post-metadata">

### Author: ![Dev\_Work](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dev_work/32/124200_2.png) [@Dev\_Work](https://meta.discourse.org/u/Dev_Work)
#### Post date: [2019 年 8 月 14 日午前 6:44 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/15 "2019-08-14T06:44:53Z")

</div>

現在の Discourse のバージョンでこれを修正するにはどうすればよいですか？  
このコードを削除すべきでしょうか？ `.where.not(visibility_level: 4) `

```class
  @@visible_group_scope = method(:visible_groups).clone
  scope :visible_groups, ->(user, order = nil, opts = {}) {
    @@visible_group_scope.call(user, order, opts)
  }
end

```

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2019 年 8 月 15 日午後 7:19 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/16 "2019-08-15T19:19:14Z")

</div>

はい、この問題についてもう少し深く調査しました。

どうやら、Babble が独自に `visibility_level` を割り当てて使用しており、次の未使用の定数（4）を採用していたようです。

数週間前、Discourse コアコードも新しい `visibility_level` を追加し、同様に次の未使用の定数（これも 4）を採用してしまいました。これにより、この定数の重複使用が発生しました。

したがって、修正は以下の 2 段階で構成されます。

- Babble が使用する `visibility_level` を変更します。これは簡単です。将来的な競合を避けるために、各プラグインが独自の `BASE_VISIBILITY_LEVEL` を登録するようにすれば完璧ですが、現時点では単に別の値（例えば 1001）を選ぶだけでも構いません。
- `visibility_level` が 4 のグループを新しい定数に変更しますが、これは Babble によって使用されていたグループに限定します。

このクエリで正しいグループが選択されますか、@gdpelican さん？

```plaintext
UPDATE groups 
SET visibility_level = 1001 
WHERE id IN (
  SELECT g.id 
  FROM topics t 
  LEFT JOIN topic_allowed_groups tag ON tag.topic_id = t.id 
  LEFT JOIN groups g ON g.id = tag.group_id 
  WHERE t.archetype='chat');

```

---

<div class="post-metadata">

### Author: ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)
#### Post date: [2019 年 8 月 16 日午前 10:43 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/17 "2019-08-16T10:43:15Z")

</div>

こんにちは、すみません。数日中に確認いたしますが、修正の一般的な概要は完璧です。バックポートが難しい部分になりますので、近々詳しく確認します。

---

<div class="post-metadata">

### Author: ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)
#### Post date: [2019 年 8 月 19 日午前 1:20 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/18 "2019-08-19T01:20:13Z")

</div>

さて、この問題の修正をプッシュしました。他に不審な点がございましたら、お知らせください。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2019 年 8 月 20 日午前 7:28 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/19 "2019-08-20T07:28:41Z")

</div>

1 つの問題が見つかりました：Backfiller 機能にはマルチサイトサポートが不足しているようです（利用可能な接続をループする必要があります）

---

<div class="post-metadata">

### Author: ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)
#### Post date: [2019 年 8 月 22 日午後 1:43 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/20 "2019-08-22T13:43:28Z")

</div>

@RGJ それについてプルリクエストを作成していただけますか？私はマージできますが、今後数日は接続が限られる予定です。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2019 年 8 月 22 日午後 5:58 UTC](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413/21 "2019-08-22T17:58:14Z")

</div>

もちろん、今週末にそれができるはずです。

[Next page](https://meta.discourse.org/t/babble-admins-cant-see-a-group-set-to-group-owner-only-visibility/123413.md?page=2)
