mirror of
				https://gitlab.com/comunic/comunicterm
				synced 2025-11-04 12:14:04 +00:00 
			
		
		
		
	Can process & return the real name of conversations
This commit is contained in:
		@@ -3,6 +3,7 @@
 | 
			
		||||
#include "conversationshelper.h"
 | 
			
		||||
#include "../api_request.h"
 | 
			
		||||
#include "../entities/conversation.h"
 | 
			
		||||
#include "../entities/conversationslist.h"
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
@@ -11,14 +12,14 @@ ConversationsHelper::ConversationsHelper()
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
vector<Conversation> ConversationsHelper::GetList()
 | 
			
		||||
ConversationsList ConversationsHelper::GetList()
 | 
			
		||||
{
 | 
			
		||||
    const auto response = ApiRequest("conversations/getList").exec();
 | 
			
		||||
 | 
			
		||||
    if(response.code() != 200)
 | 
			
		||||
        throw runtime_error("Get conversations list failed! (code: " + to_string(response.code()));
 | 
			
		||||
 | 
			
		||||
    vector<Conversation> list;
 | 
			
		||||
    ConversationsList list;
 | 
			
		||||
 | 
			
		||||
    for(auto el : response.array()) {
 | 
			
		||||
        auto obj = el.as_object();
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
class Conversation;
 | 
			
		||||
class ConversationsList;
 | 
			
		||||
 | 
			
		||||
class ConversationsHelper
 | 
			
		||||
{
 | 
			
		||||
@@ -18,5 +19,5 @@ public:
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the list of conversations of the current user
 | 
			
		||||
     */
 | 
			
		||||
    static std::vector<Conversation> GetList();
 | 
			
		||||
    static ConversationsList GetList();
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -18,9 +18,9 @@ User UserHelper::GetSingle(int id)
 | 
			
		||||
    return getMultiple(l)[id];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
map<int, User> UserHelper::getMultiple(std::vector<int> ids)
 | 
			
		||||
UsersList UserHelper::getMultiple(std::vector<int> ids)
 | 
			
		||||
{
 | 
			
		||||
    map<int, User> users;
 | 
			
		||||
    UsersList users;
 | 
			
		||||
    vector<int> toGet;
 | 
			
		||||
 | 
			
		||||
    // Check for missing users in cache
 | 
			
		||||
@@ -62,3 +62,8 @@ map<int, User> UserHelper::getMultiple(std::vector<int> ids)
 | 
			
		||||
 | 
			
		||||
    return users;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
UsersList UserHelper::getMultiple(std::set<int> ids)
 | 
			
		||||
{
 | 
			
		||||
    return getMultiple(vector<int>(ids.begin(), ids.end()));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,17 +8,18 @@
 | 
			
		||||
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <set>
 | 
			
		||||
 | 
			
		||||
#include <entities/user.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UserHelper
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    UserHelper();
 | 
			
		||||
 | 
			
		||||
    static User GetSingle(int id);
 | 
			
		||||
    static std::map<int, User> getMultiple(std::vector<int> ids);
 | 
			
		||||
    static UsersList getMultiple(std::vector<int> ids);
 | 
			
		||||
    static UsersList getMultiple(std::set<int> ids);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    static std::map<int, User> mCache;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user