/** * Returns the unread count in a JSONobject * * @return SS_HTTPResponse */ public function count() { $notifications = TimelineEvent::get_unread(Member::currentUser()); $response = new SS_HTTPResponse(json_encode(array('count' => $notifications->count())), 200); $response->addHeader('Content-Type', 'application/json'); return $response; }
public function testMarkTimelineEventAsRead() { $member = $this->objFromFixture('Member', 'reciever'); TimelineEvent::notify($member, 'Im message to u!'); $unread = TimelineEvent::get_unread($member); $this->assertEquals(1, $unread->count()); $unread->first()->markAsRead(); $this->assertEquals(0, TimelineEvent::get_unread($member)->count()); }