libkazv
Kazv::PowerLevelsDesc Class Reference

Represent a m.power_levels event. More...

#include <power-levels-desc.hpp>

Classes

struct  Private
 

Public Member Functions

 PowerLevelsDesc (const Event &e)
 Construct a PowerLevelsDesc from an event. More...
 
 ~PowerLevelsDesc ()
 
 KAZV_DECLARE_COPYABLE (PowerLevelsDesc)
 
PowerLevel powerLevelOfUser (std::string userId) const
 Get the power level of a user in the room. More...
 
bool canSendMessage (std::string userId, std::string eventType) const
 Determine whether a user can send a non-state event. More...
 
bool canSendState (std::string userId, std::string eventType) const
 Determine whether a user can send a state event. More...
 
bool canInvite (std::string userId) const
 Determine whether a user can invite someone else. More...
 
bool canKick (std::string userId) const
 Determine whether a user can kick someone else. More...
 
bool canBan (std::string userId) const
 Determine whether a user can ban someone else. More...
 
bool canRedact (std::string userId) const
 Determine whether a user can redact someone else's events. More...
 
Event normalizedEvent () const
 Get the normalized event of this. More...
 
Event originalEvent () const
 Get the original event provided when constructing this. More...
 
PowerLevelsDesc setBan (std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the power level needed to ban someone. More...
 
PowerLevelsDesc setInvite (std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the power level needed to invite someone. More...
 
PowerLevelsDesc setKick (std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the power level needed to kick someone. More...
 
PowerLevelsDesc setRedact (std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the power level needed to redact someone else's messages. More...
 
PowerLevelsDesc setEvent (std::string eventType, std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the power level needed to send an event of a particular type. More...
 
PowerLevelsDesc setEventsDefault (std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the power level needed to send a non-state event whose type is not in events. More...
 
PowerLevelsDesc setStateDefault (std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the power level needed to send a state event whose type is not in events. More...
 
PowerLevelsDesc setUser (std::string userId, std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the power level of some user. More...
 
PowerLevelsDesc setUsersDefault (std::optional< PowerLevel > powerLevel) const
 Amend the power levels event to set the default power level for users. More...
 

Detailed Description

Represent a m.power_levels event.

Constructor & Destructor Documentation

◆ PowerLevelsDesc()

Kazv::PowerLevelsDesc::PowerLevelsDesc ( const Event e)

Construct a PowerLevelsDesc from an event.

◆ ~PowerLevelsDesc()

Kazv::PowerLevelsDesc::~PowerLevelsDesc ( )
default

Member Function Documentation

◆ canBan()

bool Kazv::PowerLevelsDesc::canBan ( std::string  userId) const

Determine whether a user can ban someone else.

Parameters
userIdThe id of the user.
Returns
Whether the user can send such an event.

◆ canInvite()

bool Kazv::PowerLevelsDesc::canInvite ( std::string  userId) const

Determine whether a user can invite someone else.

Parameters
userIdThe id of the user.
Returns
Whether the user can send such an event.

◆ canKick()

bool Kazv::PowerLevelsDesc::canKick ( std::string  userId) const

Determine whether a user can kick someone else.

Parameters
userIdThe id of the user.
Returns
Whether the user can send such an event.

◆ canRedact()

bool Kazv::PowerLevelsDesc::canRedact ( std::string  userId) const

Determine whether a user can redact someone else's events.

Parameters
userIdThe id of the user.
Returns
Whether the user can send such an event.

◆ canSendMessage()

bool Kazv::PowerLevelsDesc::canSendMessage ( std::string  userId,
std::string  eventType 
) const

Determine whether a user can send a non-state event.

Parameters
userIdThe id of the user.
eventTypeThe type of the event to send.
Returns
Whether the user can send such an event.

◆ canSendState()

bool Kazv::PowerLevelsDesc::canSendState ( std::string  userId,
std::string  eventType 
) const

Determine whether a user can send a state event.

Parameters
userIdThe id of the user.
eventTypeThe type of the event to send.
Returns
Whether the user can send such an event.

◆ KAZV_DECLARE_COPYABLE()

Kazv::PowerLevelsDesc::KAZV_DECLARE_COPYABLE ( PowerLevelsDesc  )

◆ normalizedEvent()

Event Kazv::PowerLevelsDesc::normalizedEvent ( ) const

Get the normalized event of this.

Returns
The normalized event for this power levels desc.

◆ originalEvent()

Event Kazv::PowerLevelsDesc::originalEvent ( ) const

Get the original event provided when constructing this.

Returns
The original event provided when constructing this.

◆ powerLevelOfUser()

PowerLevel Kazv::PowerLevelsDesc::powerLevelOfUser ( std::string  userId) const

Get the power level of a user in the room.

Parameters
userIdThe id of the user.
Returns
The power level of the user.

◆ setBan()

PowerLevelsDesc Kazv::PowerLevelsDesc::setBan ( std::optional< PowerLevel powerLevel) const

Amend the power levels event to set the power level needed to ban someone.

Parameters
powerLevelThe new power level needed to ban someone. Use std::nullopt to remove.
Returns
A new PowerLevelsDesc that reflects the amended event.

◆ setEvent()

PowerLevelsDesc Kazv::PowerLevelsDesc::setEvent ( std::string  eventType,
std::optional< PowerLevel powerLevel 
) const

Amend the power levels event to set the power level needed to send an event of a particular type.

Parameters
eventTypeThe type of the event.
powerLevelThe new power level needed to send an event of this type. Use std::nullopt to remove.
Returns
A new PowerLevelsDesc that reflects the amended event.

◆ setEventsDefault()

PowerLevelsDesc Kazv::PowerLevelsDesc::setEventsDefault ( std::optional< PowerLevel powerLevel) const

Amend the power levels event to set the power level needed to send a non-state event whose type is not in events.

Parameters
powerLevelThe new power level needed to send a non-state event of a type not in events. Use std::nullopt to remove.
Returns
A new PowerLevelsDesc that reflects the amended event.

◆ setInvite()

PowerLevelsDesc Kazv::PowerLevelsDesc::setInvite ( std::optional< PowerLevel powerLevel) const

Amend the power levels event to set the power level needed to invite someone.

Parameters
powerLevelThe new power level needed to invite someone. Use std::nullopt to remove.
Returns
A new PowerLevelsDesc that reflects the amended event.

◆ setKick()

PowerLevelsDesc Kazv::PowerLevelsDesc::setKick ( std::optional< PowerLevel powerLevel) const

Amend the power levels event to set the power level needed to kick someone.

Parameters
powerLevelThe new power level needed to kick someone. Use std::nullopt to remove.
Returns
A new PowerLevelsDesc that reflects the amended event.

◆ setRedact()

PowerLevelsDesc Kazv::PowerLevelsDesc::setRedact ( std::optional< PowerLevel powerLevel) const

Amend the power levels event to set the power level needed to redact someone else's messages.

Parameters
powerLevelThe new power level needed to redact someone else's messages. Use std::nullopt to remove.
Returns
A new PowerLevelsDesc that reflects the amended event.

◆ setStateDefault()

PowerLevelsDesc Kazv::PowerLevelsDesc::setStateDefault ( std::optional< PowerLevel powerLevel) const

Amend the power levels event to set the power level needed to send a state event whose type is not in events.

Parameters
powerLevelThe new power level needed to send a state event of a type not in events. Use std::nullopt to remove.
Returns
A new PowerLevelsDesc that reflects the amended event.

◆ setUser()

PowerLevelsDesc Kazv::PowerLevelsDesc::setUser ( std::string  userId,
std::optional< PowerLevel powerLevel 
) const

Amend the power levels event to set the power level of some user.

Parameters
userIdThe id of the user.
powerLevelThe new power level of this user.
Returns
A new PowerLevelsDesc that reflects the amended event.

◆ setUsersDefault()

PowerLevelsDesc Kazv::PowerLevelsDesc::setUsersDefault ( std::optional< PowerLevel powerLevel) const

Amend the power levels event to set the default power level for users.

Parameters
powerLevelThe new default power level for users in the room. Use std::nullopt to remove.
Returns
A new PowerLevelsDesc that reflects the amended event.

The documentation for this class was generated from the following files: