Add the logtime to the list of properties returned by getevents. Patch
includes cleanup for code style.
Patch by murklins.
diffs (161 lines):
diff -r 243791185af8 -r fecfa5b4646a cgi-bin/ljprotocol.pl
--- a/cgi-bin/ljprotocol.pl Tue Sep 14 12:08:18 2010 +0800
+++ b/cgi-bin/ljprotocol.pl Tue Sep 14 13:42:00 2010 +0800
@@ -2199,9 +2199,9 @@ sub getevents
# okay, follow me here... see how we add the revttime predicate
# even if no beforedate key is present? you're probably saying,
- # that's retarded -- you're saying: "revttime > 0", that's like
+ # what, huh? -- you're saying: "revttime > 0", that's like
# saying, "if entry occurred at all." yes yes, but that hints
- # mysql's braindead optimizer to use the right index.
+ # mysql's optimizer to use the right index.
my $rtime_after = 0;
my $rtime_what = $is_community ? "rlogtime" : "revttime";
if ($req->{'beforedate'}) {
@@ -2314,7 +2314,7 @@ sub getevents
# common SQL template:
unless ($sql) {
- $sql = "SELECT jitemid, eventtime, security, allowmask, anum, posterid
".
+ $sql = "SELECT jitemid, eventtime, logtime, security, allowmask, anum,
posterid ".
"FROM log2 WHERE journalid=$ownerid $where $secwhere $orderby
$limit";
}
@@ -2330,22 +2330,23 @@ sub getevents
my $count = 0;
my @itemids = ();
my $res = {};
- my $events = $res->{'events'} = [];
+ my $events = $res->{events} = [];
my %evt_from_itemid;
- while (my ($itemid, $eventtime, $sec, $mask, $anum, $jposterid) =
$sth->fetchrow_array)
+ while (my ($itemid, $eventtime, $logtime, $sec, $mask, $anum, $jposterid)
= $sth->fetchrow_array)
{
$count++;
my $evt = {};
- $evt->{'itemid'} = $itemid;
+ $evt->{itemid} = $itemid;
push @itemids, $itemid;
$evt_from_itemid{$itemid} = $evt;
- $evt->{"eventtime"} = $eventtime;
+ $evt->{eventtime} = $eventtime;
+ $evt->{logtime} = $logtime;
if ($sec ne "public") {
- $evt->{'security'} = $sec;
- $evt->{'allowmask'} = $mask if $sec eq "usemask";
+ $evt->{security} = $sec;
+ $evt->{allowmask} = $mask if $sec eq "usemask";
}
$evt->{anum} = $anum;
$evt->{poster} = LJ::get_username( $jposterid )
@@ -3905,37 +3906,37 @@ sub getevents
my $rs = LJ::Protocol::do_request("getevents", $rq, \$err, $flags);
unless ($rs) {
- $res->{'success'} = "FAIL";
- $res->{'errmsg'} = LJ::Protocol::error_message($err);
+ $res->{success} = "FAIL";
+ $res->{errmsg} = LJ::Protocol::error_message($err);
return 0;
}
my $ect = 0;
my $pct = 0;
- foreach my $evt (@{$rs->{'events'}}) {
+ foreach my $evt (@{$rs->{events}}) {
$ect++;
- foreach my $f (qw(itemid eventtime security allowmask subject anum url
poster)) {
+ foreach my $f (qw(itemid eventtime logtime security allowmask subject
anum url poster)) {
if (defined $evt->{$f}) {
$res->{"events_${ect}_$f"} = $evt->{$f};
}
}
- $res->{"events_${ect}_event"} = LJ::eurl($evt->{'event'});
-
- if ($evt->{'props'}) {
- foreach my $k (sort keys %{$evt->{'props'}}) {
+ $res->{"events_${ect}_event"} = LJ::eurl($evt->{event});
+
+ if ($evt->{props}) {
+ foreach my $k (sort keys %{$evt->{props}}) {
$pct++;
- $res->{"prop_${pct}_itemid"} = $evt->{'itemid'};
+ $res->{"prop_${pct}_itemid"} = $evt->{itemid};
$res->{"prop_${pct}_name"} = $k;
- $res->{"prop_${pct}_value"} = $evt->{'props'}->{$k};
- }
- }
- }
-
- unless ($req->{'noprops'}) {
- $res->{'prop_count'} = $pct;
- }
- $res->{'events_count'} = $ect;
- $res->{'success'} = "OK";
+ $res->{"prop_${pct}_value"} = $evt->{props}->{$k};
+ }
+ }
+ }
+
+ unless ($req->{noprops}) {
+ $res->{prop_count} = $pct;
+ }
+ $res->{events_count} = $ect;
+ $res->{success} = "OK";
return 1;
}
diff -r 243791185af8 -r fecfa5b4646a doc/raw/build/protocol/getevents.mode.xml
--- a/doc/raw/build/protocol/getevents.mode.xml Tue Sep 14 12:08:18 2010 +0800
+++ b/doc/raw/build/protocol/getevents.mode.xml Tue Sep 14 13:42:00 2010 +0800
@@ -131,6 +131,10 @@ The time the user posted (or said they p
The time the user posted (or said they posted, rather, since users can
back-date posts) the item being returned.
</des></scalar></key>
+<key name="logtime" count="1"><scalar><des>
+The UTC time that the server logged when the post was first created.
+</des></scalar></key>
+
<key name="security" count="1"><scalar><des>
If this variable is not returned, then the security of the post is
<emphasis>public</emphasis>, otherwise this value will be
<emphasis>private</emphasis> or usemask.
</des></scalar></key>
@@ -190,6 +194,10 @@ Server: Apache/1.3.4 (Unix)
<value><string>2020-02-20 02:20:00</string></value>
</member>
+<member><name>logtime</name>
+<value><string>2020-02-20 08:23:48</string></value>
+
+</member>
<member><name>event</name>
<value><string>yes its true its ...</string></value>
</member>
@@ -205,6 +213,10 @@ Server: Apache/1.3.4 (Unix)
<value><struct>
<member><name>eventtime</name>
<value><string>2002-07-14 11:17:00</string></value>
+
+</member>
+<member><name>logtime</name>
+<value><string>2002-07-14 17:17:51</string></value>
</member>
<member><name>event</name>
diff -r 243791185af8 -r fecfa5b4646a htdocs/protocol.dat
--- a/htdocs/protocol.dat Tue Sep 14 12:08:18 2010 +0800
+++ b/htdocs/protocol.dat Tue Sep 14 13:42:00 2010 +0800
@@ -582,6 +582,10 @@ The unique integer ItemID of the <I>n</I
.des
The time the user posted (or said they posted, rather, since users can
back-date posts) the <I>n</I>th item being returned.
}
+{ events_<I>n</I>_logtime
+.des
+The UTC time that the server logged when the post was first created.
+}
{ events_<I>n</I>_event
.des
The <I>n</I>th event text itself. This value is first truncated if the
<TT>truncate</TT> variable is set, and then it is URL-encoded (alphanumerics
stay the same, weird symbols to <TT>%hh</TT>, and spaces to <TT>+</TT> signs,
just like URLs or post request). This allows posts with line breaks to come
back on one line.
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog