How can I clear the history of a SimpleChat pod without being in an owner role?
simpleChat.model.clear() only works if the owner is trying to clear the chat message history.
Solved! Go to Solution.
Views
Replies
Total Likes
Forgot the node configuration, that is something like this:
nodeConfiguration = {
"accessModel" => RTC::UserRole::VIEWER,
"publishModel" => RTC::UserRoleVIEWER,
"persistItems" => true,
"modifyAnyItem" => false,
"userDependedItems" => false,
"sessionDependentItems" => false,
"itemStorageScheme" => RTC::NodeConfiguration::STORAGE_SCHEME_QUEUE,
"allowPrivateMessage" => true
}
then you can pass it to the createNode method, as it's done in the ActionScript code.
Make sure you set all the properties according to your particular chat configuration.
Views
Replies
Total Likes
You can not clear history without being an owner because the chat is a collaborative one. If a non-owner is allowed, then he will clean other user's history as well.
So, to clear history, you need to be an owner.
Thanks
Hironmay Basu
Yeah, the idea here is that any normal user isn't allowed to modify or
delete someone else's chat - this is controlled by the
NodeConfiguration.modifyAnyItem field for that node (otherwise, an evil
hacker could rewrite or remove what you said!).
One thing you could consider is using server-to-server calls to remove the
node and re-add it. Your client could call your server, then route the calls
to us, logged in with your dev credentials (so, OWNER).
hope that helps,
nigel
Thanks. I understand why it's not ideal.
If I did want to allow any publisher to be able to clear the chat messages, could just enable "modifyAnyItem" on the history node of simpleChat? Would simpleChat.model.clear() work then?
Views
Replies
Total Likes
To my own question. No, it doesn't look like that works even if "modifyAnyItem" is checked.
Do you have an example of using the API to remove and then re-add a node?
I see how simpleChat.model.clear() clears the history:
if (_collectionNode.isSynchronized && _collectionNode.canUserConfigure(_userManager.myUserID)) {
_collectionNode.removeNode(HISTORY_NODE_EVERYONE);
_collectionNode.createNode(HISTORY_NODE_EVERYONE, new NodeConfiguration(UserRoles.VIEWER, UserRoles.VIEWER, true, false, false, _isClearAfterSessionRemoved, NodeConfiguration.STORAGE_SCHEME_QUEUE, _allowPrivateChat));
_collectionNode.removeNode(HISTORY_NODE_PARTICIPANTS);
_collectionNode.createNode(HISTORY_NODE_PARTICIPANTS, new NodeConfiguration(UserRoles.PUBLISHER, UserRoles.VIEWER, true, false, false, _isClearAfterSessionRemoved, NodeConfiguration.STORAGE_SCHEME_QUEUE));
_collectionNode.removeNode(HISTORY_NODE_HOSTS);
_collectionNode.createNode(HISTORY_NODE_HOSTS, new NodeConfiguration(UserRoles.OWNER, UserRoles.VIEWER, true, false, false, _isClearAfterSessionRemoved, NodeConfiguration.STORAGE_SCHEME_QUEUE));
_messagesSeen = new Object();
}
but an example of how this would translate into the API would be helpful (I'm using the Ruby API, but whatever you might have it in is fine).
Views
Replies
Total Likes
After you create an AccountManager object and login:
am.removeNode("roomName", "chatPodId", "history")
am.createNode("roomName", "chatPodId, "history")
Views
Replies
Total Likes
Forgot the node configuration, that is something like this:
nodeConfiguration = {
"accessModel" => RTC::UserRole::VIEWER,
"publishModel" => RTC::UserRoleVIEWER,
"persistItems" => true,
"modifyAnyItem" => false,
"userDependedItems" => false,
"sessionDependentItems" => false,
"itemStorageScheme" => RTC::NodeConfiguration::STORAGE_SCHEME_QUEUE,
"allowPrivateMessage" => true
}
then you can pass it to the createNode method, as it's done in the ActionScript code.
Make sure you set all the properties according to your particular chat configuration.
Views
Replies
Total Likes
Views
Likes
Replies