diff --git a/config/models b/config/models index 997cb0a..e08105c 100644 --- a/config/models +++ b/config/models @@ -362,6 +362,15 @@ Ticket UniqueTicketFollowers followers UniqueTicketAccept accept +LocalTicket + ticket TicketId + discuss DiscussionId + followers FollowerSetId + + UniqueLocalTicket ticket + UniqueLocalTicketDiscussion discuss + UniqueLocalTicketFollowers followers + TicketAuthorLocal ticket TicketId author PersonId diff --git a/migrations/2020_02_05_local_ticket.model b/migrations/2020_02_05_local_ticket.model new file mode 100644 index 0000000..89b3219 --- /dev/null +++ b/migrations/2020_02_05_local_ticket.model @@ -0,0 +1,8 @@ +LocalTicket + ticket TicketId + discuss DiscussionId + followers FollowerSetId + + UniqueLocalTicket ticket + UniqueLocalTicketDiscussion discuss + UniqueLocalTicketFollowers followers diff --git a/migrations/2020_02_05_mig.model b/migrations/2020_02_05_mig.model new file mode 100644 index 0000000..74e8e22 --- /dev/null +++ b/migrations/2020_02_05_mig.model @@ -0,0 +1,37 @@ +Discussion + +FollowerSet + +Project + +Person + +OutboxItem + +Ticket + project ProjectId + number Int Maybe + created UTCTime + title Text -- HTML + source Text -- Pandoc Markdown + description Text -- HTML + assignee PersonId Maybe + status Text + closed UTCTime + closer PersonId Maybe + discuss DiscussionId + followers FollowerSetId + accept OutboxItemId + + UniqueTicketDiscussion discuss + UniqueTicketFollowers followers + UniqueTicketAccept accept + +LocalTicket + ticket TicketId + discuss DiscussionId + followers FollowerSetId + + UniqueLocalTicket ticket + UniqueLocalTicketDiscussion discuss + UniqueLocalTicketFollowers followers diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index 0306300..23ed92d 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -862,6 +862,11 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT , ticketFollowers = fsid , ticketAccept = obiidAccept } + insert_ LocalTicket + { localTicketTicket = tid + , localTicketDiscuss = did + , localTicketFollowers = fsid + } insert_ TicketAuthorLocal { ticketAuthorLocalTicket = tid , ticketAuthorLocalAuthor = pidAuthor diff --git a/src/Vervis/ActivityPub/Recipient.hs b/src/Vervis/ActivityPub/Recipient.hs index a8b71c6..082ef8a 100644 --- a/src/Vervis/ActivityPub/Recipient.hs +++ b/src/Vervis/ActivityPub/Recipient.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2019 by fr33domlover . + - Written in 2019, 2020 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - @@ -122,7 +122,7 @@ parseLocalRecipient r = -- the code that fetches the actual recipients from the DB. ------------------------------------------------------------------------------- -data LocalTicketRecipientDirect = LocalTicketTeam | LocalTicketFollowers +data LocalTicketRecipientDirect = LocalTicketTeam | LocalTicketFollowerz deriving (Eq, Ord) data LocalProjectRecipientDirect @@ -188,7 +188,7 @@ groupedRecipientFromCollection groupedRecipientFromCollection (LocalPersonCollectionTicketFollowers shr prj num) = LocalSharerRelated shr $ LocalProjectRelated prj $ - LocalTicketRelated num LocalTicketFollowers + LocalTicketRelated num LocalTicketFollowerz groupedRecipientFromCollection (LocalPersonCollectionRepoTeam shr rp) = LocalSharerRelated shr $ LocalRepoRelated rp $ @@ -301,7 +301,7 @@ groupLocalRecipients initial = LocalTicketDirectSet False False f s LocalTicketTeam = s { localRecipTicketTeam = True } - f s LocalTicketFollowers = + f s LocalTicketFollowerz = s { localRecipTicketFollowers = True } lrr2set = LocalRepoRelatedSet . foldl' f initial . NE.map unwrap where diff --git a/src/Vervis/Federation/Ticket.hs b/src/Vervis/Federation/Ticket.hs index 9f903fa..09bc064 100644 --- a/src/Vervis/Federation/Ticket.hs +++ b/src/Vervis/Federation/Ticket.hs @@ -277,6 +277,11 @@ projectOfferTicketF , ticketFollowers = fsid , ticketAccept = obiidAccept } + insert_ LocalTicket + { localTicketTicket = tid + , localTicketDiscuss = did + , localTicketFollowers = fsid + } insert_ TicketAuthorRemote { ticketAuthorRemoteTicket = tid , ticketAuthorRemoteAuthor = raidAuthor diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 0ebada2..e3c1ea5 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -1233,6 +1233,17 @@ changes hLocal ctx = , removeUnique "Ticket" "UniqueTicket" -- 187 , setFieldMaybe "Ticket" "number" + -- 188 + , addEntities model_2020_02_05 + -- 189 + , unchecked $ lift $ do + ts <- selectList ([] :: [Filter Ticket189]) [] + let makeLT (Entity tid t) = LocalTicket189 + { localTicket189Ticket = tid + , localTicket189Discuss = ticket189Discuss t + , localTicket189Followers = ticket189Followers t + } + insertMany_ $ map makeLT ts ] migrateDB diff --git a/src/Vervis/Migration/Model.hs b/src/Vervis/Migration/Model.hs index 828f7ec..3894a6a 100644 --- a/src/Vervis/Migration/Model.hs +++ b/src/Vervis/Migration/Model.hs @@ -139,6 +139,10 @@ module Vervis.Migration.Model , RemoteCollection159Generic (..) , RemoteCollection159 , model_2020_01_05 + , model_2020_02_05 + , Ticket189 + , Ticket189Generic (..) + , LocalTicket189Generic (..) ) where @@ -146,7 +150,6 @@ import Data.ByteString (ByteString) import Data.Text (Text) import Data.Time (UTCTime) import Database.Persist.Class (EntityField, Unique) ---import Database.Persist.JSON (PersistJSONValue) import Database.Persist.Schema.Types (Entity) import Database.Persist.Schema.SQL () import Database.Persist.Sql (SqlBackend) @@ -281,3 +284,8 @@ makeEntitiesMigration "159" model_2020_01_05 :: [Entity SqlBackend] model_2020_01_05 = $(schema "2020_01_05") + +model_2020_02_05 :: [Entity SqlBackend] +model_2020_02_05 = $(schema "2020_02_05_local_ticket") + +makeEntitiesMigration "189" $(modelFile "migrations/2020_02_05_mig.model")