refactor(users-add): shorten upsert-avs
This commit is contained in:
parent
cba73bf2ca
commit
2235e64444
@ -75,9 +75,8 @@ postCAddUserR tid ssh csh = do
|
|||||||
|
|
||||||
registerUsers :: CourseId -> Map Text (Maybe Text) -> WriterT [Message] (YesodJobDB UniWorX) ()
|
registerUsers :: CourseId -> Map Text (Maybe Text) -> WriterT [Message] (YesodJobDB UniWorX) ()
|
||||||
registerUsers cid usersToRegister = do
|
registerUsers cid usersToRegister = do
|
||||||
avsUsers :: Map Text (Maybe UserId) <- fmap Map.fromList . forM (Map.keys usersToRegister) $ \userIdent -> do
|
avsUsers :: Map Text (Maybe UserId) <- flip Map.traverseWithKey usersToRegister $ \userIdent _ ->
|
||||||
mUser <- liftHandler $ upsertAvsUser userIdent -- TODO: upsertAvsUser should return whole Entity
|
liftHandler $ upsertAvsUser userIdent -- TODO: upsertAvsUser should return whole Entity
|
||||||
return (userIdent, mUser)
|
|
||||||
|
|
||||||
if
|
if
|
||||||
| null avsUsers
|
| null avsUsers
|
||||||
@ -127,6 +126,6 @@ registerUser cid uid = exceptT tell tell $ do
|
|||||||
, CourseParticipantState =. CourseParticipantActive
|
, CourseParticipantState =. CourseParticipantActive
|
||||||
]
|
]
|
||||||
lift . lift . audit $ TransactionCourseParticipantEdit cid uid
|
lift . lift . audit $ TransactionCourseParticipantEdit cid uid
|
||||||
lift . lift . queueDBJob . JobQueueNotification $ NotificationCourseRegistered uid cid
|
lift . lift . queueDBJob . JobQueueNotification $ NotificationCourseRegistered uid cid -- TODO: send Notification at all?
|
||||||
|
|
||||||
return $ mempty { aurRegisterSuccess = Set.singleton uid }
|
return $ mempty { aurRegisterSuccess = Set.singleton uid }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user