@@ -28,6 +28,12 @@ MembershipService::MembershipService(ThreadSafePtr<PubNub> pubnub, std::weak_ptr
28
28
{}
29
29
30
30
std::tuple<std::vector<Pubnub::Membership>, Pubnub::Page, int , Pubnub::String> MembershipService::get_channel_members (const String& channel_id, const ChannelDAO& channel_data, const Pubnub::String &filter, const Pubnub::String &sort, int limit, const Pubnub::Page &page) const {
31
+
32
+ if (limit < 0 || limit > PN_MAX_LIMIT)
33
+ {
34
+ throw std::invalid_argument (" can't get members, limit has to be within 0 - " + std::to_string (PN_MAX_LIMIT) + " range" );
35
+ }
36
+
31
37
String include_string = " custom,channel,totalCount,customChannel" ;
32
38
33
39
auto get_channel_members_response = [this , channel_id, include_string, limit, filter, sort, page] {
@@ -70,6 +76,11 @@ std::tuple<std::vector<Pubnub::Membership>, Pubnub::Page, int, Pubnub::String> M
70
76
}
71
77
72
78
std::tuple<std::vector<Pubnub::Membership>, Pubnub::Page, int , Pubnub::String> MembershipService::get_user_memberships (const String& user_id, const UserDAO& user_data, const Pubnub::String &filter, const Pubnub::String &sort, int limit, const Pubnub::Page &page) const {
79
+ if (limit < 0 || limit > PN_MAX_LIMIT)
80
+ {
81
+ throw std::invalid_argument (" can't get memberships, limit has to be within 0 - " + std::to_string (PN_MAX_LIMIT) + " range" );
82
+ }
83
+
73
84
String include_string = " totalCount,custom,channel,customChannel,channelType,status,channelStatus" ;
74
85
75
86
auto get_memberships_response = [this , user_id, include_string, filter, sort, limit, page] {
@@ -272,6 +283,12 @@ int MembershipService::get_unread_messages_count_one_channel(const Membership& m
272
283
}
273
284
274
285
std::vector<std::tuple<Pubnub::Channel, Pubnub::Membership, int >> MembershipService::get_all_unread_messages_counts (const Pubnub::String &filter, const Pubnub::String &sort, int limit, const Pubnub::Page &page) const {
286
+
287
+ if (limit < 0 || limit > PN_MAX_LIMIT)
288
+ {
289
+ throw std::invalid_argument (" can't get unread messages counts, limit has to be within 0 - " + std::to_string (PN_MAX_LIMIT) + " range" );
290
+ }
291
+
275
292
auto chat_service_shared = chat_service.lock ();
276
293
std::vector<std::tuple<Pubnub::Channel, Pubnub::Membership, int >> return_tuples;
277
294
@@ -318,6 +335,11 @@ std::vector<std::tuple<Pubnub::Channel, Pubnub::Membership, int>> MembershipServ
318
335
319
336
std::tuple<Pubnub::Page, int , int , std::vector<Pubnub::Membership>> MembershipService::mark_all_messages_as_read (const Pubnub::String &filter, const Pubnub::String &sort, int limit, const Pubnub::Page& page) const
320
337
{
338
+ if (limit < 0 || limit > PN_MAX_LIMIT)
339
+ {
340
+ throw std::invalid_argument (" can't mark all messages as read, limit has to be within 0 - " + std::to_string (PN_MAX_LIMIT) + " range" );
341
+ }
342
+
321
343
auto chat_service_shared = chat_service.lock ();
322
344
std::tuple<Pubnub::Page, int , int , std::vector<Pubnub::Membership>> return_tuple;
323
345
0 commit comments