Api for seen state, perl preferred

Bron Gondwana brong at fastmail.fm
Wed May 20 05:23:24 EDT 2009

On Wed, May 20, 2009 at 08:36:47AM +0200, LALOT Dominique wrote:
> Hello,
> I'm following a previous thread. I would like to be able to open a seen
> skiplist database in order to verify if a particular user has red its mail.
> If possible, a way to do that in PERL would be perfect.
> Thanks in advance

That's, um, tricky actually.

You need to read the uniqueid of the mailbox from the cyrus.header file
first, then read the contents of the skiplist file.  The easiest way to
do that is `cyr_dbtool /path/to/seen/file.db skiplist get $uniqueid`,
which will give you the seen record.  You then need to parse that for
uniqueids - it's in the format:


where range is either a single integer or $low:$high where low and high
are both integers - in which case all the messages in that range
inclusive are seen.

There's some other stuff in that seen record as well.  Here we go:

[brong at imap3 hm]$ cat /mnt/meta8/slot308/store23/meta/b/user/brong/cyrus.header | grep user.brong
user.brong      6af857f64475158a

[brong at imap3 hm]$ /usr/cyrus/bin/cyr_dbtool -C /etc/imapd-slot308-master.conf /mnt/meta8/slot308/store23/conf/user/b/brong.seen skiplist get 6af857f64475158a
1 1242810803 386716 1242800567 1:386615

Looks like I've seen all my email!  Also notice 4 other
fields at the start:

<version> <lastread> <lastuid> <lastchange> <seen_items>

Here's a more interesting couple of folders to give you an idea
of what ranges look like:

798b2df94146a5fe        1 1095746485 1526 1095740252 1:559,561:772,774:920,922:1109,1111:1115,1117:1138,1140:1170,1172:1195,1197:1521
798b2df941576261        1 1125837870 34307 1123831223 1:28289,29118,30871,31887,31935,32058,32209:32210,32214:32219,32222,32228

So - in summary.  It's not easy.  Some plumbing required...
(lastuid gives you "\Recent" as per the IMAP flag - anything
newer than that is recent!)


More information about the Info-cyrus mailing list