ditched x/c functionality in favor of binary expansion
This commit is contained in:
+3
-6
@@ -40,12 +40,9 @@ In case of multi-line responses, the newline separator must be "\n" character
|
|||||||
Request: GET /list.txt
|
Request: GET /list.txt
|
||||||
Response: newline-separated list of echo_name:msg_count:echo_description
|
Response: newline-separated list of echo_name:msg_count:echo_description
|
||||||
|
|
||||||
- Fetching the echo message count (IDEC extension) -
|
|
||||||
|
|
||||||
Request: GET /x/c/echo.1.name/echo.2.name/..
|
|
||||||
Response: newline separated list of echo_name:msg_count
|
|
||||||
|
|
||||||
Note: msg_count must not decrease even if some messages are deleted.
|
Note: msg_count must not decrease even if some messages are deleted.
|
||||||
|
Some nodes (e.g. ii-php) still can violate this rule, so the message count
|
||||||
|
reported by nodes still should not be the basis for any client-side logic.
|
||||||
|
|
||||||
- Listing messages in the echo (s) -
|
- Listing messages in the echo (s) -
|
||||||
|
|
||||||
@@ -87,7 +84,7 @@ The maximum length of the tmsg field must be 87382 bytes.
|
|||||||
|
|
||||||
Request: GET /x/features
|
Request: GET /x/features
|
||||||
Response: newline-separated list of supported non-standard URL paths
|
Response: newline-separated list of supported non-standard URL paths
|
||||||
(x/c, u/e, /list.txt etc)
|
(u/e, /list.txt etc)
|
||||||
|
|
||||||
Note: if the /x/features path is unavailable, the client must assume that no
|
Note: if the /x/features path is unavailable, the client must assume that no
|
||||||
IDEC extensions except /list.txt are supported by the server.
|
IDEC extensions except /list.txt are supported by the server.
|
||||||
|
|||||||
+29
-15
@@ -212,31 +212,45 @@ proc fetchiidb {url echos dbfile dolog maxids} {
|
|||||||
} else {
|
} else {
|
||||||
set echos [split $echos "/,;"]
|
set echos [split $echos "/,;"]
|
||||||
}
|
}
|
||||||
if {$dolog eq 1} {puts "Echos to fetch: $echos"}
|
|
||||||
set echos [lmap s $echos {string trim $s}]
|
set echos [lmap s $echos {string trim $s}]
|
||||||
|
if {$dolog eq 1} {puts "Echos to fetch: $echos"}
|
||||||
|
if {$dolog eq 1} {puts "Building message indexes..."}
|
||||||
# get the IDEC extended feature list
|
# get the IDEC extended feature list
|
||||||
set featurelist ""
|
set featurelist ""
|
||||||
catch {set featurelist [getfile [string cat $url "/x/features"]]}
|
catch {set featurelist [getfile [string cat $url "/x/features"]]}
|
||||||
set featurelist [lmap s [split $featurelist \n] {string trim $s}]
|
set featurelist [lmap s [split $featurelist \n] {string trim $s}]
|
||||||
set datalines ""
|
set datalines ""
|
||||||
if {([lsearch $featurelist x/c] > -1 ) && ([lsearch $featurelist u/e] > -1)} {
|
if {[lsearch $featurelist u/e] > -1} {
|
||||||
# get message count in every echo of our choice
|
# echoname => localcount map
|
||||||
set countdata [getfile [string cat $url "/x/c/" [join $echos "/"]]]
|
set localcounts [msgdb eval {SELECT `echoname`, COUNT(`id`) FROM `msg` GROUP BY `echoname`;}]
|
||||||
foreach cd $countdata {
|
foreach ename $echos {
|
||||||
set cdparts [split $cd :]
|
if {$ename ne ""} {
|
||||||
if {[llength $cdparts] > 1} {
|
set localdata ""
|
||||||
set ename [lindex $cdparts 0]
|
set localcount 0
|
||||||
set rcount [lindex $cdparts 1]
|
if {[dict exists $localcounts $ename]} {
|
||||||
set lcount [msgdb eval {SELECT COUNT (DISTINCT `id`) FROM `msg` WHERE `echoname` = $ename;}]
|
set localcount [dict get $localcounts $ename]
|
||||||
# get the difference between remote and local counts
|
}
|
||||||
set diff [expr {$rcount - $lcount}]
|
if {$localcount > 12} {
|
||||||
if {$diff > 0} { # we have something to fetch
|
set diff 6
|
||||||
|
set needsync 1
|
||||||
|
while {$needsync eq 1} {
|
||||||
|
incr diff $diff
|
||||||
|
set localdata [getfile [string cat $url "/u/e/" $ename "/-$diff:1"]]
|
||||||
|
# control message id
|
||||||
|
set cmsg [string trim [lindex [split $localdata \n] 1]]
|
||||||
|
msgdb eval {SELECT `msgid` FROM `msg` WHERE `msgid` = $cmsg;} row {
|
||||||
|
if {[string trim $row(msgid)] eq $cmsg} {
|
||||||
|
set needsync 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
set localdata [getfile [string cat $url "/u/e/" $ename "/-$diff:$diff"]]
|
set localdata [getfile [string cat $url "/u/e/" $ename "/-$diff:$diff"]]
|
||||||
|
} else {
|
||||||
|
set localdata [getfile [string cat $url "/u/e/" $ename]]
|
||||||
|
}
|
||||||
append datalines [string trim $localdata] \n
|
append datalines [string trim $localdata] \n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} else { # no extended feature support, pass the echo list and fetch the message IDs
|
} else { # no extended feature support, pass the echo list and fetch the message IDs
|
||||||
set echodata [getfile [string cat $url "/u/e/" [join $echos "/"]]]
|
set echodata [getfile [string cat $url "/u/e/" [join $echos "/"]]]
|
||||||
set datalines [split $echodata \n]
|
set datalines [split $echodata \n]
|
||||||
|
|||||||
Reference in New Issue
Block a user