Brad Fitzpatrick (bradfitz) wrote in lj_dev,
Brad Fitzpatrick
bradfitz
lj_dev

Patch request: checkfriends fixing

Checkfriends is dumb right now. It's supposed to:

1) be very light-weight
2) be correct

Right now it's only half of #1 and half of #2. The join it does is quick, at the expense of correctness. (it reports changes when a friend posts a private/masked entry you don't have access to read... so it shouldn't flash red at you)

But it could be more correct and more light-weight.

Somebody please implement this:

* add a new userprop to userproplist --- "lastfriendpost"
* when somebody posts:
1) if private, do nothing
2) if public:

REPLACE INTO userprop (userid, upropid, value) SELECT userid, $propid, NOW() FROM friends WHERE friendid=$journalid

(where you figure out $propid ahead of time from using LJ::load_props or whatever which caches that info, rather than joining on another table there)

3) if usemask: same SELECT query as above, except with a join against friend again, to check the allowmask the $journalid gives to the friendof ... something like: (double check this)

REPLACE INTO userprop (userid, upropid, value) SELECT o.userid, $propid, NOW() FROM friends o, friends r WHERE o.friendid=$journalid AND r.userid=$journalid AND r.friendid=o.userid AND r.groupmask & $allowmask

(Mnemonic: "o" = friend of, "r" = reverse friendship)
(where $allowmask is already defined in the "postevent" code in ljprotocol.pl)

Then... once you check that's all working, modify checkfriends to not do the join, and instead just load_user_props("lastfriendpost").

Should be a fun straight-forward project that'll be rewarding (improving #1 and #2 above).
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 5 comments