improved fetching to get better response from relays

reduced days fetched.

combined calls.
This commit is contained in:
Vishal
2022-12-24 11:22:57 +05:30
parent d393acdef8
commit 9efa5a60f2
6 changed files with 84 additions and 37 deletions

View File

@@ -451,15 +451,19 @@ String getMentionRequest(String subscriptionId, Set<String> ids, int numUserEven
return strSubscription1 + getCommaSeparatedQuotedStrs(ids) + strSubscription2;
}
String getIdAndMentionRequest(String subscriptionId, Set<String> ids, int numUserEvents, int sinceWhen, String tagToGet) {
String strTime = "";
if( sinceWhen != 0) {
strTime = ', "since": ${sinceWhen.toString()}';
String getIdAndMentionRequest(String subscriptionId, Set<String> ids, int numUserEvents, int idSinceWhen, int mentionSinceWhen, String tagToGet, String idString) {
String idStrTime = "", mentionStrTime = "";
if( idSinceWhen != 0) {
idStrTime = ', "since": ${idSinceWhen.toString()}';
}
if( mentionSinceWhen != 0) {
mentionStrTime = ', "since": ${mentionSinceWhen.toString()}';
}
var strSubscription1 = '["REQ","$subscriptionId",{ "$tagToGet": [';
var strSubscription2 ='], "limit": $numUserEvents $strTime } ]';
String req = '["REQ","$subscriptionId",{ "$tagToGet": [' + getCommaSeparatedQuotedStrs(ids) + '], "limit": $numUserEvents $strTime},{"authors":[' + getCommaSeparatedQuotedStrs(ids) + ']} ]';
var strSubscription2 ='], "limit": $numUserEvents $idStrTime } ]';
String req = '["REQ","$subscriptionId",{ "$tagToGet": [' + getCommaSeparatedQuotedStrs(ids) + '], "limit": $numUserEvents $mentionStrTime},{"$idString":[' + getCommaSeparatedQuotedStrs(ids) + ']$idStrTime}]';
//print("Created id and mention request: $req");
return req;
}