1 {-# LANGUAGE TypeFamilies, OverloadedStrings #-}
    2 module Model.Notification.Types
    3   ( module Model.Notification.Notice
    4   , Notification(..)
    5   , blankNotification
    6   ) where
    7 
    8 import Model.Time
    9 import Model.Id.Types
   10 import Model.Kind
   11 import Model.Party
   12 import Model.Volume.Types
   13 import Model.Container.Types
   14 import Model.Segment
   15 import Model.Asset.Types
   16 import Model.Comment.Types
   17 import Model.Tag.Types
   18 import Model.Permission.Types
   19 import Model.Release.Types
   20 import Model.Notification.Notice
   21 
   22 type instance IdType Notification = Int32
   23 
   24 data Notification = Notification
   25   { notificationId :: Id Notification
   26   , notificationTarget :: !Account
   27   , notificationNotice :: !Notice
   28   , notificationTime :: Timestamp
   29   , notificationDelivered :: !Delivery
   30   , notificationAgent :: PartyRow
   31   , notificationParty :: Maybe PartyRow
   32   , notificationVolume :: Maybe VolumeRow
   33   , notificationPermission :: Maybe Permission
   34   , notificationContainerId :: Maybe (Id Container)
   35   , notificationSegment :: Maybe Segment
   36   , notificationAssetId :: Maybe (Id Asset)
   37   , notificationRelease :: Maybe Release
   38   , notificationCommentId :: Maybe (Id Comment)
   39   , notificationTag :: Maybe Tag
   40   }
   41 
   42 instance Kinded Notification where
   43   kindOf _ = "notification"
   44 
   45 blankNotification :: Account -> Notice -> Notification
   46 blankNotification target notice = Notification
   47   { notificationId = error "blankNotification"
   48   , notificationTarget = target
   49   , notificationNotice = notice
   50   , notificationTime = error "blankNotification"
   51   , notificationDelivered = DeliveryNone
   52   , notificationAgent = partyRow nobodyParty
   53   , notificationParty = Nothing
   54   , notificationVolume = Nothing
   55   , notificationPermission = Nothing
   56   , notificationContainerId = Nothing
   57   , notificationSegment = Nothing
   58   , notificationAssetId = Nothing
   59   , notificationRelease = Nothing
   60   , notificationCommentId = Nothing
   61   , notificationTag = Nothing
   62   }