-
Notifications
You must be signed in to change notification settings - Fork 65
Conversation
src/Cache.cc
Outdated
if (res) { | ||
try { | ||
StateEvent<GuestAccess> msg = json::parse(std::string(event.data(), event.size())); | ||
if (msg.content.guest_access == AccessState::CanJoin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just write is as return msg.content.guest_access == AccessState::CanJoin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot of the PR!
In order to change data on the server, you'll have to use the HTTP client API. The cache is read only by the client which means that only the events from /sync
are written to it.
src/Cache.cc
Outdated
return false; | ||
} | ||
catch (const json::exception &e) { | ||
qWarning() << QString::fromStdString(e.what()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the QString::fromStdString
method here.
src/Cache.cc
Outdated
@@ -435,6 +435,8 @@ Cache::saveState(const mtx::responses::Sync &res) | |||
updatedInfo.avatar_url = | |||
getRoomAvatarUrl(txn, statesdb, membersdb, QString::fromStdString(room.first)) | |||
.toStdString(); | |||
updatedInfo.join_rule = getRoomJoinRules(txn, statesdb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already saved in the states db. You can remove those lines.
src/Cache.cc
Outdated
@@ -467,6 +469,8 @@ Cache::saveInvites(lmdb::txn &txn, const std::map<std::string, mtx::responses::I | |||
updatedInfo.avatar_url = | |||
getInviteRoomAvatarUrl(txn, statesdb, membersdb).toStdString(); | |||
updatedInfo.is_invite = true; | |||
updatedInfo.join_rule = getRoomJoinRules(txn, statesdb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
include/Cache.h
Outdated
@@ -164,6 +169,9 @@ class Cache : public QObject | |||
|
|||
//! Calculate & return the name of the room. | |||
QString getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb); | |||
//! Get room join rules | |||
JoinRule getRoomJoinRules(lmdb::txn &txn, lmdb::dbi &statesdb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: getRoomJoinRule
|
||
void | ||
RoomSettings::save_and_close() { | ||
// TODO: Save access changes to the room |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To save the changes you'll have to send a state event using the http API.
src/Cache.cc
Outdated
return msg.content.join_rule; | ||
} | ||
catch (const json::exception &e) { | ||
qWarning() << QString::fromStdString(e.what()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here for QString::fromStdString
src/Cache.cc
Outdated
@@ -604,6 +611,8 @@ Cache::getRoomInfo(const std::vector<std::string> &rooms) | |||
RoomInfo tmp = | |||
json::parse(std::string(data.data(), data.size())); | |||
tmp.member_count = getInviteMembersDb(txn, room).size(txn); | |||
tmp.join_rule = getRoomJoinRules(txn, statesdb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invited rooms are not viewable in nheko so we don't need those.
src/Cache.cc
Outdated
|
||
// Check if the room is joined. | ||
if (lmdb::dbi_get(txn, roomsDb_, lmdb::val(room), data)) { | ||
try { | ||
RoomInfo tmp = json::parse(std::string(data.data(), data.size())); | ||
tmp.member_count = getMembersDb(txn, room).size(txn); | ||
tmp.join_rule = getRoomJoinRules(txn, statesdb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you copy those lines in Cache::singleRoomInfo
also, and make the RoomSettings
page call that method instead of Cache::getRoomInfo
.
include/Cache.h
Outdated
@@ -74,6 +76,9 @@ struct RoomInfo | |||
bool is_invite = false; | |||
//! Total number of members in the room. | |||
int16_t member_count = 0; | |||
//! Who can access to the room. | |||
JoinRule join_rule = JoinRule::Public; | |||
bool guest_access = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add those in the to_json
& from_json
methods also.
src/dialogs/RoomSettings.cpp
Outdated
accessCombo = new QComboBox(this); | ||
accessCombo->addItem(tr("Anyone and guests")); | ||
accessCombo->addItem(tr("Anyone")); | ||
accessCombo->addItem(tr("Inviteds")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invited users
src/dialogs/RoomSettings.cpp
Outdated
accessCombo->setDisabled(true); | ||
accessLabel->setStyleSheet("font-size: 15px;"); | ||
|
||
if(info_.join_rule == JoinRule::Public) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some braces around the outer if/else
statement.
- Join rules - Guest access
In Room settings you can see who can join to the room, whether it's just the inviteds, anyone or anyone including guests.
I would have liked to implement the possibility of changing it, but I am not familiar with the source code and I did not find a similar function with which I could be oriented.