automatically tag broadcasts with the "Broadcast" study topic

pull/6119/head
Thibault Duplessis 2020-03-03 22:03:19 -06:00
parent e1854ce94e
commit fef47d2e4c
4 changed files with 14 additions and 1 deletions

View File

@ -69,7 +69,8 @@ final class RelayApi(
from = Study.From.Relay(none).some
),
user
) inject relay
) >>
studyApi.addTopics(relay.studyId, List("Broadcast")) inject relay
}
def requestPlay(id: Relay.Id, v: Boolean): Funit = WithRelay(id) { relay =>

View File

@ -71,6 +71,10 @@ case class Study(
def light = LightStudy(isPublic, members.contributorIds)
def topicsOrEmpty = topics | StudyTopics.empty
def addTopics(ts: StudyTopics) = copy(
topics = topics.fold(ts)(_ ++ ts).some
)
}
object Study {

View File

@ -740,6 +740,10 @@ final class StudyApi(
}
}
def addTopics(studyId: Study.Id, topics: List[String]) = sequenceStudy(studyId) { study =>
studyRepo.updateTopics(study addTopics StudyTopics.fromStrs(topics))
}
def editStudy(studyId: Study.Id, data: Study.Data)(who: Who) = sequenceStudy(studyId) { study =>
canActAsOwner(study, who.u) flatMap { asOwner =>
data.settings.ifTrue(asOwner) ?? { settings =>

View File

@ -29,6 +29,10 @@ case class StudyTopics(value: List[StudyTopic]) extends AnyVal {
def diff(other: StudyTopics) = StudyTopics {
value.toSet.diff(other.value.toSet).toList
}
def ++(other: StudyTopics) = StudyTopics {
value.toSet.++(other.value.toSet).toList
}
}
object StudyTopics {