diff --git a/app/org/maproulette/framework/graphql/schemas/TeamSchema.scala b/app/org/maproulette/framework/graphql/schemas/TeamSchema.scala index 93475b3d..b44fc399 100644 --- a/app/org/maproulette/framework/graphql/schemas/TeamSchema.scala +++ b/app/org/maproulette/framework/graphql/schemas/TeamSchema.scala @@ -102,7 +102,10 @@ class TeamSchema @Inject() (override val service: TeamService) case Some(description) => Some(description) case None => team.description }, - avatarURL = context.arg(TeamSchema.avatarUrlArg) + avatarURL = context.arg(TeamSchema.avatarUrlArg) match { + case Some(avatarURL) => Some(avatarURL) + case None => team.avatarURL + } ), user ) @@ -205,10 +208,10 @@ object TeamSchema extends DefaultWrites { OptionInputType(StringType), "The description of the object" ) - val avatarUrlArg: Argument[String] = + val avatarUrlArg: Argument[Option[String]] = Argument( "avatarURL", - StringType, + OptionInputType(StringType), "An avatar URL representing the object" ) } diff --git a/app/org/maproulette/framework/model/Group.scala b/app/org/maproulette/framework/model/Group.scala index 980e5dbb..85ae0cd9 100644 --- a/app/org/maproulette/framework/model/Group.scala +++ b/app/org/maproulette/framework/model/Group.scala @@ -22,7 +22,7 @@ case class Group( id: Long, name: String, description: Option[String] = None, - avatarURL: String, + avatarURL: Option[String] = None, groupType: Int = Group.GROUP_TYPE_STANDARD, created: DateTime = DateTime.now(), modified: DateTime = DateTime.now() @@ -34,7 +34,7 @@ object Group extends CommonField { (JsPath \ "id").read[Long] and (JsPath \ "name").read[String] and (JsPath \ "description").readNullable[String] and - (JsPath \ "avatarURL").read[String] and + (JsPath \ "avatarURL").readNullable[String] and (JsPath \ "groupType").read[Int] and ((JsPath \ "created").read[DateTime] or Reads.pure(DateTime.now())) and ((JsPath \ "modified").read[DateTime] or Reads.pure(DateTime.now())) diff --git a/app/org/maproulette/framework/repository/UserRepository.scala b/app/org/maproulette/framework/repository/UserRepository.scala index 2ba69c1b..ade689ba 100644 --- a/app/org/maproulette/framework/repository/UserRepository.scala +++ b/app/org/maproulette/framework/repository/UserRepository.scala @@ -170,13 +170,7 @@ class UserRepository @Inject() ( case None => val group = this.serviceManager.group .create( - Group( - -1, - s"User ${follower.id} Following", - Some(""), - "", - groupType = Group.GROUP_TYPE_FOLLOWING - ) + Group(-1, s"User ${follower.id} Following", groupType = Group.GROUP_TYPE_FOLLOWING) ) .get this.setupGroup("following_group", group.id, follower.id) @@ -189,13 +183,7 @@ class UserRepository @Inject() ( case None => val group = this.serviceManager.group .create( - Group( - -1, - s"User ${followed.id} Followers", - Some(""), - "", - groupType = Group.GROUP_TYPE_FOLLOWERS - ) + Group(-1, s"User ${followed.id} Followers", groupType = Group.GROUP_TYPE_FOLLOWERS) ) .get this.setupGroup("followers_group", group.id, followed.id) diff --git a/test/org/maproulette/framework/repository/GroupMemberRepositorySpec.scala b/test/org/maproulette/framework/repository/GroupMemberRepositorySpec.scala index 4f01a927..39b1c55b 100644 --- a/test/org/maproulette/framework/repository/GroupMemberRepositorySpec.scala +++ b/test/org/maproulette/framework/repository/GroupMemberRepositorySpec.scala @@ -256,7 +256,7 @@ class GroupMemberRepositorySpec(implicit val application: Application) extends F -1, name, Some("A test group"), - "http://www.gravatar.com/avatar/?d=identicon", + Some("http://www.gravatar.com/avatar/?d=identicon"), groupType ) } diff --git a/test/org/maproulette/framework/repository/GroupRepositorySpec.scala b/test/org/maproulette/framework/repository/GroupRepositorySpec.scala index 6ab06d1e..36ec5c86 100644 --- a/test/org/maproulette/framework/repository/GroupRepositorySpec.scala +++ b/test/org/maproulette/framework/repository/GroupRepositorySpec.scala @@ -33,24 +33,24 @@ class GroupRepositorySpec(implicit val application: Application) extends Framewo } "create a group" taggedAs GroupTag in { - val createdGroup = this.repository.create(Group(-1, "RandomCreateGroup", Some(""), "")).get + val createdGroup = this.repository.create(Group(-1, "RandomCreateGroup")).get val retrievedGroup = this.repository.retrieve(createdGroup.id) retrievedGroup.get mustEqual createdGroup } "update a group" taggedAs GroupTag in { - val randomGroup = this.repository.create(Group(-1, "RandomGroup", Some(""), "")).get + val randomGroup = this.repository.create(Group(-1, "RandomGroup")).get this.repository.update( - Group(randomGroup.id, "UpdatedName", Some("Updated description"), "new_avatar_url") + Group(randomGroup.id, "UpdatedName", Some("Updated description"), Some("new_avatar_url")) ) val group = this.service.retrieve(randomGroup.id) group.get.name mustEqual "UpdatedName" group.get.description.get mustEqual "Updated description" - group.get.avatarURL mustEqual "new_avatar_url" + group.get.avatarURL.get mustEqual "new_avatar_url" } "delete a group" taggedAs GroupTag in { - val group = this.repository.create(Group(-1, "RandomDeleteGroup", Some(""), "")).get + val group = this.repository.create(Group(-1, "RandomDeleteGroup")).get this.repository.delete(group) this.service.retrieve(group.id) mustEqual None } @@ -73,7 +73,7 @@ class GroupRepositorySpec(implicit val application: Application) extends Framewo -1, name, Some("A test group"), - "http://www.gravatar.com/avatar/?d=identicon" + Some("http://www.gravatar.com/avatar/?d=identicon") ) } } diff --git a/test/org/maproulette/framework/service/GroupServiceSpec.scala b/test/org/maproulette/framework/service/GroupServiceSpec.scala index c660f0e0..f7d66a00 100644 --- a/test/org/maproulette/framework/service/GroupServiceSpec.scala +++ b/test/org/maproulette/framework/service/GroupServiceSpec.scala @@ -163,7 +163,7 @@ class GroupServiceSpec(implicit val application: Application) extends FrameworkH -1, name, Some("A test group"), - "http://www.gravatar.com/avatar/?d=identicon" + Some("http://www.gravatar.com/avatar/?d=identicon") ) } } diff --git a/test/org/maproulette/framework/util/FrameworkHelper.scala b/test/org/maproulette/framework/util/FrameworkHelper.scala index 2a53baf6..09744fca 100644 --- a/test/org/maproulette/framework/util/FrameworkHelper.scala +++ b/test/org/maproulette/framework/util/FrameworkHelper.scala @@ -146,7 +146,7 @@ trait FrameworkHelper extends PlaySpec with BeforeAndAfterAll with MockitoSugar -1, name, Some("A test team"), - "http://www.gravatar.com/avatar/?d=identicon" + Some("http://www.gravatar.com/avatar/?d=identicon") ) }