Skip to content

Commit

Permalink
Merge branch 'develop' into 325-refactor-post-reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdworkin committed Jan 16, 2023
2 parents 710edd9 + df88b15 commit 1af4fdc
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 39 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Refactor post reactions [#325](https://github.com/rokwire/groups-building-block/issues/325)

## [1.11.0] - 2023-01-13
### Added
- Create internal API for updating group's date updated [#335](https://github.com/rokwire/groups-building-block/issues/335)

## [1.10.1] - 2023-01-10
### Changed
- Split date modified field and introduce member & managed member modified date fields [#330](https://github.com/rokwire/groups-building-block/issues/330)

## [1.9.5] - 2023-01-04
### Changed
- Report of offensive speech automatic title [#328](https://github.com/rokwire/groups-building-block/issues/328)

## [1.9.4] - 2022-12-21
### Changed
- Group admins must not see direct messages if they are not listed explicitly within. the ACL list[#326](https://github.com/rokwire/groups-building-block/issues/326)

## [1.9.3] - 2022-12-20
### Fixed
- Delete group post request fails [#321](https://github.com/rokwire/groups-building-block/issues/321)

## [1.9.2] - 2022-12-14
### Fixed
- Admin must make posts and reactions no matter of group settings [#315](https://github.com/rokwire/groups-building-block/issues/315)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DATE ?= $(shell date +%FT%T%z)
BIN = $(CURDIR)/build
BIN = $(CURDIR)/bin
BASE = $(CURDIR)
MODULE = $(shell cd $(BASE) && $(GO) list -m)
PKGS = $(or $(PKG),$(shell cd $(BASE) && $(GO) list ./...))
Expand Down
8 changes: 7 additions & 1 deletion core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Services interface {

CreateGroup(clientID string, current *model.User, group *model.Group) (*string, *utils.GroupError)
UpdateGroup(clientID string, current *model.User, group *model.Group) *utils.GroupError
UpdateGroupDateUpdated(clientID string, groupID string) error
DeleteGroup(clientID string, current *model.User, id string) error
GetAllGroups(clientID string) ([]model.Group, error)
GetGroups(clientID string, current *model.User, filter model.GroupsFilter) ([]model.Group, error)
Expand Down Expand Up @@ -121,6 +122,10 @@ func (s *servicesImpl) UpdateGroup(clientID string, current *model.User, group *
return s.app.updateGroup(clientID, current, group)
}

func (s *servicesImpl) UpdateGroupDateUpdated(clientID string, groupID string) error {
return s.app.updateGroupDateUpdated(clientID, groupID)
}

func (s *servicesImpl) DeleteGroup(clientID string, current *model.User, id string) error {
return s.app.deleteGroup(clientID, current, id)
}
Expand Down Expand Up @@ -337,7 +342,8 @@ type Storage interface {
UpdateGroup(clientID string, current *model.User, group *model.Group) *utils.GroupError
UpdateGroupWithMembership(clientID string, current *model.User, group *model.Group, memberships []model.GroupMembership) *utils.GroupError
UpdateGroupSyncTimes(context storage.TransactionContext, clientID string, group *model.Group) error
UpdateGroupStats(context storage.TransactionContext, clientID string, id string, resetUpdateDate bool, resetStats bool) error
UpdateGroupStats(context storage.TransactionContext, clientID string, id string, resetUpdateDate bool, resetMembershipUpdateDate bool, resetManagedMembershipUpdateDate bool, resetStats bool) error
UpdateGroupDateUpdated(clientID string, groupID string) error
DeleteGroup(clientID string, id string) error
FindGroup(context storage.TransactionContext, clientID string, groupID string, userID *string) (*model.Group, error)
FindGroupWithContext(context storage.TransactionContext, clientID string, groupID string, userID *string) (*model.Group, error)
Expand Down
6 changes: 4 additions & 2 deletions core/model/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ type Group struct {
Members []Member `json:"members,omitempty" bson:"members,omitempty"`
Stats GroupStats `json:"stats" bson:"stats"`

DateCreated time.Time `json:"date_created" bson:"date_created"`
DateUpdated *time.Time `json:"date_updated" bson:"date_updated"`
DateCreated time.Time `json:"date_created" bson:"date_created"`
DateUpdated *time.Time `json:"date_updated" bson:"date_updated"`
DateMembershipUpdated *time.Time `json:"date_membership_updated" bson:"date_membership_updated"`
DateManagedMembershipUpdated *time.Time `json:"date_managed_membership_updated" bson:"date_managed_membership_updated"`

AuthmanEnabled bool `json:"authman_enabled" bson:"authman_enabled"`
AuthmanGroup *string `json:"authman_group" bson:"authman_group"`
Expand Down
12 changes: 10 additions & 2 deletions core/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ func (app *Application) updateGroup(clientID string, current *model.User, group
return nil
}

func (app *Application) updateGroupDateUpdated(clientID string, groupID string) error {
err := app.storage.UpdateGroupDateUpdated(clientID, groupID)
if err != nil {
return err
}
return nil
}

func (app *Application) deleteGroup(clientID string, current *model.User, id string) error {
err := app.storage.DeleteGroup(clientID, id)
if err != nil {
Expand Down Expand Up @@ -594,7 +602,7 @@ func (app *Application) reportPostAsAbuse(clientID string, current *model.User,
if sendToDean && !sendToGroupAdmins {
subject = "Report violation of Student Code to Dean of Students"
} else if !sendToDean && sendToGroupAdmins {
subject = "Report obscene, threatening, or harassing content to Group Administrators"
subject = "Report of Obscene, Harassing, or Threatening Content to Group Administrators"
} else {
subject = "Report violation of Student Code to Dean of Students and obscene, threatening, or harassing content to Group Administrators"
}
Expand Down Expand Up @@ -1161,7 +1169,7 @@ func (app *Application) syncAuthmanGroupMemberships(clientID string, authmanGrou
log.Printf("%d memberships removed from Authman %s\n", deleteCount, *authmanGroup.AuthmanGroup)
}

err = app.storage.UpdateGroupStats(nil, clientID, authmanGroup.ID, true, true)
err = app.storage.UpdateGroupStats(nil, clientID, authmanGroup.ID, false, false, true, true)
if err != nil {
log.Printf("Error updating group stats for '%s' - %s", *authmanGroup.AuthmanGroup, err)
}
Expand Down
47 changes: 47 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,47 @@ const docTemplate = `{
}
}
},
"/api/int/group/{group-id}/date_updated": {
"post": {
"security": [
{
"IntAPIKeyAuth": []
}
],
"description": "Updates the date updated field of the desired group",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Internal"
],
"operationId": "IntUpdateGroupDateUpdated",
"parameters": [
{
"type": "string",
"description": "APP",
"name": "APP",
"in": "header",
"required": true
},
{
"type": "string",
"description": "Group ID",
"name": "group-id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/int/group/{group-id}/events": {
"post": {
"security": [
Expand Down Expand Up @@ -2983,6 +3024,12 @@ const docTemplate = `{
"date_created": {
"type": "string"
},
"date_managed_membership_updated": {
"type": "string"
},
"date_membership_updated": {
"type": "string"
},
"date_updated": {
"type": "string"
},
Expand Down
47 changes: 47 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,47 @@
}
}
},
"/api/int/group/{group-id}/date_updated": {
"post": {
"security": [
{
"IntAPIKeyAuth": []
}
],
"description": "Updates the date updated field of the desired group",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Internal"
],
"operationId": "IntUpdateGroupDateUpdated",
"parameters": [
{
"type": "string",
"description": "APP",
"name": "APP",
"in": "header",
"required": true
},
{
"type": "string",
"description": "Group ID",
"name": "group-id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/int/group/{group-id}/events": {
"post": {
"security": [
Expand Down Expand Up @@ -2979,6 +3020,12 @@
"date_created": {
"type": "string"
},
"date_managed_membership_updated": {
"type": "string"
},
"date_membership_updated": {
"type": "string"
},
"date_updated": {
"type": "string"
},
Expand Down
30 changes: 30 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ definitions:
description: this is indicative and it's not required for update APIs
date_created:
type: string
date_managed_membership_updated:
type: string
date_membership_updated:
type: string
date_updated:
type: string
description:
Expand Down Expand Up @@ -2213,6 +2217,32 @@ paths:
- AppUserAuth: []
tags:
- Client-V1
/api/int/group/{group-id}/date_updated:
post:
consumes:
- application/json
description: Updates the date updated field of the desired group
operationId: IntUpdateGroupDateUpdated
parameters:
- description: APP
in: header
name: APP
required: true
type: string
- description: Group ID
in: path
name: group-id
required: true
type: string
produces:
- application/json
responses:
"200":
description: ""
security:
- IntAPIKeyAuth: []
tags:
- Internal
/api/int/group/{group-id}/events:
post:
consumes:
Expand Down
Loading

0 comments on commit 1af4fdc

Please sign in to comment.