コード例 #1
0
ファイル: organization.go プロジェクト: messagedb/messagedb
// ListPublicMembers retusn the list of all public members. Each user can control the visibility of their membership. This will
// only includes the members that have chosen to do so.
//
// GET /orgs/:org/public_members
//
func (c *OrganizationsController) ListPublicMembers(ctx *gin.Context) {

	org := getOrganizationFromContext(ctx)
	orgService, err := services.NewOrganizationService(org, getCurrentUser(ctx))
	if err != nil {
		if c.WriteTrace {
			c.Logger.Printf("Failed to create OrganizationService for org: %v", org)
		}
		helpers.JSONResponseInternalServerError(ctx, err)
		return
	}

	members, err := orgService.GetPublicMembers()
	if err != nil {
		helpers.JSONResponseInternalServerError(ctx, err)
		return
	}

	helpers.JSONResponseCollection(ctx, presenters.MemberCollectionPresenter(members))
}
コード例 #2
0
ファイル: user.go プロジェクト: messagedb/messagedb
// ListUserConversations lists all conversations for a specific user
//
// GET /users/:username/conversations
//
func (c *UsersController) ListUserConversations(ctx *gin.Context) {

	user := getCurrentUser(ctx)

	userService, err := services.NewUserService(user)
	if err != nil {
		if c.WriteTrace {
			c.Logger.Printf("Failed to create UserService for user: %v", user)
		}
		helpers.JSONResponseInternalServerError(ctx, err)
		return
	}

	members, err := userService.ListMemberships()
	if err != nil {
		helpers.JSONResponseInternalServerError(ctx, err)
		return
	}

	helpers.JSONResponseObject(ctx, presenters.MemberCollectionPresenter(members))
}