From 7945435587704c5abd075140bdd46c11db93c255 Mon Sep 17 00:00:00 2001
From: Luke Barnard <luke@matrix.org>
Date: Fri, 6 Apr 2018 14:06:32 +0100
Subject: [PATCH] When exposing group state, return is_openly_joinable

as opposed to join_policy, which is really only pertinent to the
synapse implementation of the group server.

By doing this we keep the group server concept extensible by
allowing arbitrarily complex rules for deciding whether a group
is openly joinable.
---
 synapse/groups/groups_server.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/synapse/groups/groups_server.py b/synapse/groups/groups_server.py
index 8310dea031..290eec7127 100644
--- a/synapse/groups/groups_server.py
+++ b/synapse/groups/groups_server.py
@@ -407,6 +407,11 @@ class GroupsServerHandler(object):
         group_description = yield self.store.get_group(group_id)
 
         if group_description:
+            join_policy = group_description['join_policy']
+            del group_description['join_policy']
+
+            group_description['is_openly_joinable'] = join_policy == "open"
+
             defer.returnValue(group_description)
         else:
             raise SynapseError(404, "Unknown group")