mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-24 21:44:17 +00:00
implement leavegroup
This commit is contained in:
parent
7dc7065d07
commit
1341bfcfe9
@ -1127,7 +1127,7 @@ void storeGroupDM(const string &groupAlias, const StoredDirectMsg &stoDM)
|
||||
GroupChat &group = m_groups[groupAlias];
|
||||
|
||||
BOOST_FOREACH(string const &member, group.m_members) {
|
||||
if( m_users.count(member) ) {
|
||||
if( m_users.count(member) && !m_users.at(member).m_ignoreGroups.count(groupAlias) ) {
|
||||
storeNewDM(member,groupAlias,stoDM);
|
||||
}
|
||||
}
|
||||
@ -3579,10 +3579,10 @@ Value newgroupdescription(const Array& params, bool fHelp)
|
||||
|
||||
Value leavegroup(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 4 )
|
||||
if (fHelp || params.size() != 2 )
|
||||
throw runtime_error(
|
||||
"leavegroup <username> <groupalias>\n"
|
||||
"Stop receive chats from group");
|
||||
"Stop receiving chats from group");
|
||||
|
||||
string strUser = params[0].get_str();
|
||||
string strGroupAlias = params[1].get_str();
|
||||
@ -3594,12 +3594,8 @@ Value leavegroup(const Array& params, bool fHelp)
|
||||
if (!m_users.count(strUser))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "unknown user");
|
||||
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "not implemented");
|
||||
/*
|
||||
* The idea is to remove strGroupAlias from m_users[strUser].m_directmsg and
|
||||
* also add strGroupAlias to a m_users[strUser].m_ignoreGroups list to prevent
|
||||
* being invited again. however how would one revert a leavegroup?
|
||||
*/
|
||||
m_users[strUser].m_directmsg.erase(strGroupAlias);
|
||||
m_users[strUser].m_ignoreGroups.insert(strGroupAlias);
|
||||
|
||||
return Value();
|
||||
}
|
||||
|
@ -174,6 +174,14 @@ int saveUserData(std::string const& filename, std::map<std::string,UserData> con
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( udata.m_ignoreGroups.size() ) {
|
||||
entry &userData = userDict[i->first];
|
||||
entry &ignoreGroupsList = userData["ignore_groups"];
|
||||
BOOST_FOREACH( std::string const &n, udata.m_ignoreGroups) {
|
||||
ignoreGroupsList.list().push_back(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<char> buf;
|
||||
@ -252,6 +260,16 @@ int loadUserData(std::string const& filename, std::map<std::string,UserData> &us
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const lazy_entry *ignoreGroupsList = userData->dict_find("ignore_groups");
|
||||
if( ignoreGroupsList ) {
|
||||
if( ignoreGroupsList->type() != lazy_entry::list_t ) goto data_error;
|
||||
|
||||
for( int j = 0; j < ignoreGroupsList->list_size(); j++ ) {
|
||||
udata.m_ignoreGroups.insert( ignoreGroupsList->list_string_value_at(j) );
|
||||
}
|
||||
}
|
||||
|
||||
users[userDict.dict_at(i).first] = udata;
|
||||
}
|
||||
return 0;
|
||||
|
@ -33,6 +33,8 @@ struct UserData {
|
||||
std::set<std::string> m_mentionsKeys;
|
||||
// known posts mentioning this user (by users in m_following)
|
||||
std::vector<libtorrent::entry> m_mentionsPosts;
|
||||
// group chats to ignore
|
||||
std::set<std::string> m_ignoreGroups;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user