Commit graph

12 commits

Author SHA1 Message Date
jenkins-bot 6eba89d400 Merge "Add accessor for bundled events in EventPresentationModel" 2015-11-23 23:43:41 +00:00
Kunal Mehta 9057196d21 Add accessor for bundled events in EventPresentationModel
The implementation of this sucks as the presentation model
should not be making database queries. But the API it provides
is what we want and will be supported even if the backend
implementation is changed.

Change-Id: Ifd0d11260990fd0e00e8f32eee273f9717d3e1fb
2015-11-23 15:13:31 -08:00
Matthias Mullie 0ef4df8e15 Expose more data through API
Instead of relying on the frontend to render, this enables the frontend
to do it.

The API will now accept a new format: 'model', which is basically the
presentation model's data in json format.

Some of the render code is currently only in the backend (e.g. get icon
path from icon type) so other api formats will stay available. At some
point, however, we may be able to kill those.

Bug: T115418
Change-Id: Ibc3ad54c94d6ea9bf751f3927cf69e1d062f4780
2015-11-20 19:27:34 +00:00
Stephane Bisson b3ab132ffd Extract getMessageWithAgent
`getMessageWithAgent` is used by `getHeaderMessage` is can
be reused by other presentation models who need the
agent in their body message.

Bug: T118059
Change-Id: I0cbccaeb8b6e60d03bc75bc85c74591619b4399a
2015-11-18 09:47:24 -08:00
Kunal Mehta 40667ca7d4 EventPresentationModel: Add accessor for current user's username
Only to be used for GENDER purposes.

Bug: T118058
Change-Id: I5cf0563374ac1eaf934fecbf4bb68d35fa287edd
2015-11-12 14:34:24 -08:00
Stephane Bisson 7e1a6e7b6f Output body in flyout
* Also rename getBodyText to getBodyMessage
  since it returns a Message.

Change-Id: I2aad6f766407c13625b1c35df3ae209f75849970
2015-11-04 16:24:37 -05:00
Kunal Mehta 38e54e14fb Allow notifications to not have a primary link
Because 'welcome' doesn't.

Returning `false` indicates that there is no link, and the
FlyoutFormatter was updated accordingly.

Change-Id: Ifd329b396f3361fc7c08c607a6407181ffdb8bf6
2015-11-02 15:55:17 -08:00
Kunal Mehta 74b50cad30 Move some boilerplate code into EchoEventFormatter
The conversion of EchoEvent into a EchoEventPresentationModel is now
done by EchoFlyoutFormatter, instead of having each subclass do it. It
also does the canRender() check so subclasses don't need to worry about
it.

The subclasses no longer have access to the underlying EchoEvent object,
so the timestamp is exposed in EchoEventPresentationModel.

Change-Id: I7f0a650373eebac7aa2231b1795b51a6d031ad67
2015-10-29 21:22:54 +00:00
Kunal Mehta 39edc4ce48 Document that text from getSecondaryLinks() isn't escaped
Change-Id: Ia87faa54df7631522e41871d7bbb37345d5bce0e
2015-10-29 00:35:13 -07:00
Kunal Mehta 1e5ab0331e Fix @return doc on EchoEventPresentationModel::getPrimaryLink()
Change-Id: I5ab5df0706395aa5393d2470ebbeadbaa4e7fe6b
2015-10-29 00:34:01 -07:00
Kunal Mehta ba957d399a Allow presentation models to indicate a notification can't be formatted
Adds EchoEventPresentationModel::canRender() for notification types to
indicate that something can't be rendered if for example, a page is
deleted.

In that case, the notification is marked as read in a deferred update.
All callers were also updated to check if the notification was formatted
properly.

Bug: T116888
Change-Id: Idb975feaec893ef86c41cc487102e3539c07e328
2015-10-28 18:28:08 -07:00
Kunal Mehta 56c4b95087 Clean up and refactor formatting system
The workflow to format a notification is
* Get EchoEvent, User, and Language
* Get EchoEventFormatter implementation for notification type
** EchoEventFormatter returns structured data about each part of the
notification (header, body, primary link, secondary link(s))
* Each output type will have a formatter class (e.g.
EchoSpecialNotificationsFormatter, EchoPlainTextEmailFormatter) which
takes a EchoEventPresentationModel and generates whatever it wants
(HTML, plain-text email, etc).

Included is an example conversion of the user-rights and mention
formatters. The previous infrastructure will remain in place for
backwards compatability until other extensions can be updated.

Bug: T107823
Change-Id: I4397872a7ec062148dfcb066ddd8ab83f40486ac
2015-10-19 10:00:23 -07:00