Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 3549b5e

Browse files
committed
Fix the default power-level of invite and ensure the chosen user can actually invite people.
1 parent 0437602 commit 3549b5e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

synapse/handlers/event_auth.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import logging
1415
from typing import TYPE_CHECKING, Collection, List, Optional, Union
1516

1617
from synapse import event_auth
@@ -30,6 +31,8 @@
3031
if TYPE_CHECKING:
3132
from synapse.server import HomeServer
3233

34+
logger = logging.getLogger(__name__)
35+
3336

3437
class EventAuthHandler:
3538
"""
@@ -109,7 +112,7 @@ async def get_user_which_could_invite(
109112
SynapseError if no appropriate user is found.
110113
"""
111114
power_level_event_id = current_state_ids.get((EventTypes.PowerLevels, ""))
112-
invite_level = 50
115+
invite_level = 0
113116
users_default_level = 0
114117
if power_level_event_id:
115118
power_level_event = await self._store.get_event(power_level_event_id)
@@ -129,8 +132,15 @@ async def get_user_which_could_invite(
129132
default=None,
130133
)
131134

132-
# Return the chosen user.
133-
if chosen_user:
135+
# Return the chosen if they can issue invites.
136+
user_power_level = users.get(chosen_user, users_default_level)
137+
if chosen_user and user_power_level >= invite_level:
138+
logger.error(
139+
"Found a user who can issue invites %s with power level %d >= invite level %d",
140+
chosen_user,
141+
user_power_level,
142+
invite_level,
143+
)
134144
return chosen_user
135145

136146
# No user was found.

0 commit comments

Comments
 (0)