Authentication-Results: mail-b.sr.ht; dkim=pass header.d=emersion.fr header.i=@emersion.fr Received: from mail-4018.proton.ch (mail-4018.proton.ch [185.70.40.18]) by mail-b.sr.ht (Postfix) with ESMTPS id A32D711EF31 for <~emersion/soju-dev@lists.sr.ht>; Thu, 29 Sep 2022 12:45:37 +0000 (UTC) Date: Thu, 29 Sep 2022 12:45:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail3; t=1664455535; x=1664714735; bh=Uvj8RkNkgUdLk28Ig7SDBzjg2vJEmDA/oGNqAWEI2uE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=dAlpFObS5tHSeOTIeHpAB60DYbOgYyso2xDsAbevzfQeUpevRwe3We4jiMS8brLwx aEVF4KohUmI3E/PoQbj9+SOsUwnrVullQODTGNi0tMrcLO05KAUyQR8zQ9mO3TmMCs hA9CW7iFuphE+V5PjRoz1ua+/Yu81Xup4gfzZiJ3YE8ZLGsDOYTGxcqlvHf0ijrGHT lOlADsO6Q74/2j++YxKZY2A7BT5r7CwrroMCg6BehCynmhcDqcNYRgwctcK2HTF8+i yfRQBKk/fV0Ko/ZnR+oy/d3fq2fMUnlQKWYbzbAsS5Ml0fAw1nP8FXYl8LAybqHSWB Y3VtZ0b+RXjDw== To: delthas From: Simon Ser Cc: ~emersion/soju-dev@lists.sr.ht Subject: Re: [PATCH] Fix clearing webpush targets after any MARKREAD Message-ID: In-Reply-To: <20220928172350.16206-1-delthas@dille.cc> References: <20220928172350.16206-1-delthas@dille.cc> Feedback-ID: 1358184:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Nice! A few comments below. On Wednesday, September 28th, 2022 at 19:23, delthas wro= te: > diff --git a/irc.go b/irc.go > index bb17d64..dd56f36 100644 > --- a/irc.go > +++ b/irc.go > @@ -459,10 +459,24 @@ func (cm *monitorCasemapMap) ForEach(f func(name st= ring, online bool)) { > =09} > } > =20 > -type casemapSet struct{ casemapMap } > +type pushTargetCasemapMap struct{ casemapMap } > =20 > -func (cs *casemapSet) Add(name string) { > -=09cs.set(name, nil) > +func (cm *pushTargetCasemapMap) Get(name string) (last time.Time) { > +=09if v :=3D cm.get(name); v =3D=3D nil { > +=09=09return time.Time{} > +=09} else { > +=09=09return v.(time.Time) > +=09} > +} > + > +func (cm *pushTargetCasemapMap) Set(name string, last time.Time) { > +=09cm.set(name, last) > +} > + > +func (cm *pushTargetCasemapMap) ForEach(f func(name string, last time.Ti= me)) { > +=09for _, entry :=3D range cm.m { > +=09=09f(entry.originalKey, entry.value.(time.Time)) > +=09} > } Can we drop the ForEach impl if it's not used anywhere? > =20 > func isWordBoundary(r rune) bool { > diff --git a/upstream.go b/upstream.go > index e1030a2..180da98 100644 > --- a/upstream.go > +++ b/upstream.go > @@ -551,7 +551,9 @@ func (uc *upstreamConn) handleMessage(ctx context.Con= text, msg *irc.Message) err > =20 > =09=09if highlight || uc.isOurNick(target) { > =09=09=09go uc.network.broadcastWebPush(msg) > -=09=09=09uc.network.pushTargets.Add(bufferName) > +=09=09=09if timestamp, err :=3D time.Parse(xirc.ServerTimeLayout, string= (msg.Tags["time"])); err =3D=3D nil { > +=09=09=09=09uc.network.pushTargets.Set(bufferName, timestamp) > +=09=09=09} Hm, what happens if upstream doesn't support server-time? We should probabl= y fall back to time.Time or something right?