当前位置: 首页>>代码示例>>Golang>>正文


Golang model.TeamFromJson函数代码示例

本文整理汇总了Golang中github.com/mattermost/platform/model.TeamFromJson函数的典型用法代码示例。如果您正苦于以下问题:Golang TeamFromJson函数的具体用法?Golang TeamFromJson怎么用?Golang TeamFromJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TeamFromJson函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: createTeamFromSSO

func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) {
	params := mux.Vars(r)
	service := params["service"]

	sso := utils.Cfg.GetSSOService(service)
	if sso != nil && !sso.Enable {
		c.SetInvalidParam("createTeamFromSSO", "service")
		return
	}

	team := model.TeamFromJson(r.Body)

	if team == nil {
		c.SetInvalidParam("createTeamFromSSO", "team")
		return
	}

	if !isTreamCreationAllowed(c, team.Email) {
		return
	}

	team.PreSave()

	team.Name = model.CleanTeamName(team.Name)

	if err := team.IsValid(); err != nil {
		c.Err = err
		return
	}

	team.Id = ""

	found := true
	count := 0
	for found {
		if found = FindTeamByName(c, team.Name, "true"); c.Err != nil {
			return
		} else if found {
			team.Name = team.Name + strconv.Itoa(count)
			count += 1
		}
	}

	if result := <-Srv.Store.Team().Save(team); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		rteam := result.Data.(*model.Team)

		if _, err := CreateDefaultChannels(c, rteam.Id); err != nil {
			c.Err = nil
			return
		}

		data := map[string]string{"follow_link": c.GetSiteURL() + "/" + rteam.Name + "/signup/" + service}
		w.Write([]byte(model.MapToJson(data)))

	}

}
开发者ID:saundsr,项目名称:platform,代码行数:60,代码来源:team.go

示例2: createTeam

func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {

	team := model.TeamFromJson(r.Body)

	if team == nil {
		c.SetInvalidParam("createTeam", "team")
		return
	}

	if utils.Cfg.ServiceSettings.Mode != utils.MODE_DEV {
		c.Err = model.NewAppError("createTeam", "The mode does not allow network creation without a valid invite", "")
		return
	}

	if result := <-Srv.Store.Team().Save(team); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		rteam := result.Data.(*model.Team)

		if _, err := CreateDefaultChannels(c, rteam.Id); err != nil {
			c.Err = nil
			return
		}

		if rteam.AllowValet {
			CreateValet(c, rteam)
			if c.Err != nil {
				return
			}
		}

		w.Write([]byte(rteam.ToJson()))
	}
}
开发者ID:kingland,项目名称:platform,代码行数:35,代码来源:team.go

示例3: createTeam

func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {
	team := model.TeamFromJson(r.Body)
	rteam := CreateTeam(c, team)
	if c.Err != nil {
		return
	}

	w.Write([]byte(rteam.ToJson()))
}
开发者ID:narita-takeru,项目名称:platform,代码行数:9,代码来源:team.go

示例4: createTeam

func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {
	if utils.Cfg.ServiceSettings.DisableEmailSignUp {
		c.Err = model.NewAppError("createTeam", "Team sign-up with email is disabled.", "")
		c.Err.StatusCode = http.StatusNotImplemented
		return
	}

	team := model.TeamFromJson(r.Body)

	if team == nil {
		c.SetInvalidParam("createTeam", "team")
		return
	}

	if !isTreamCreationAllowed(c, team.Email) {
		return
	}

	if utils.Cfg.ServiceSettings.Mode != utils.MODE_DEV {
		c.Err = model.NewAppError("createTeam", "The mode does not allow network creation without a valid invite", "")
		return
	}

	if result := <-Srv.Store.Team().Save(team); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		rteam := result.Data.(*model.Team)

		if _, err := CreateDefaultChannels(c, rteam.Id); err != nil {
			c.Err = err
			return
		}

		if rteam.AllowValet {
			CreateValet(c, rteam)
			if c.Err != nil {
				return
			}
		}

		w.Write([]byte(rteam.ToJson()))
	}
}
开发者ID:JessBot,项目名称:platform,代码行数:44,代码来源:team.go

示例5: updateTeam

func updateTeam(c *Context, w http.ResponseWriter, r *http.Request) {

	team := model.TeamFromJson(r.Body)

	if team == nil {
		c.SetInvalidParam("updateTeam", "team")
		return
	}

	team.Id = c.Session.TeamId

	if !c.IsTeamAdmin() {
		c.Err = model.NewAppError("updateTeam", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
		c.Err.StatusCode = http.StatusForbidden
		return
	}

	var oldTeam *model.Team
	if result := <-Srv.Store.Team().Get(team.Id); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		oldTeam = result.Data.(*model.Team)
	}

	oldTeam.DisplayName = team.DisplayName
	oldTeam.InviteId = team.InviteId
	oldTeam.AllowOpenInvite = team.AllowOpenInvite
	oldTeam.AllowTeamListing = team.AllowTeamListing
	oldTeam.CompanyName = team.CompanyName
	oldTeam.AllowedDomains = team.AllowedDomains
	//oldTeam.Type = team.Type

	if result := <-Srv.Store.Team().Update(oldTeam); result.Err != nil {
		c.Err = result.Err
		return
	}

	oldTeam.Sanitize()

	w.Write([]byte(oldTeam.ToJson()))
}
开发者ID:raghavenc5,项目名称:TabGen,代码行数:42,代码来源:team.go

示例6: createTeam

func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {
	team := model.TeamFromJson(r.Body)

	if team == nil {
		c.SetInvalidParam("createTeam", "team")
		return
	}

	var user *model.User
	if len(c.Session.UserId) > 0 {
		uchan := app.Srv.Store.User().Get(c.Session.UserId)

		if result := <-uchan; result.Err != nil {
			c.Err = result.Err
			return
		} else {
			user = result.Data.(*model.User)
			team.Email = user.Email
		}
	}

	if !isTeamCreationAllowed(c, team.Email) {
		return
	}

	rteam, err := app.CreateTeam(team)
	if err != nil {
		c.Err = err
		return
	}

	if user != nil {
		err := app.JoinUserToTeam(team, user)
		if err != nil {
			c.Err = err
			return
		}
	}

	w.Write([]byte(rteam.ToJson()))
}
开发者ID:ZJvandeWeg,项目名称:platform,代码行数:41,代码来源:team.go

示例7: createTeam

func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {

	team := model.TeamFromJson(r.Body)

	if team == nil {
		c.SetInvalidParam("createTeam", "team")
		return
	}

	if utils.Cfg.ServiceSettings.Mode != utils.MODE_DEV {
		c.Err = model.NewAppError("createTeam", "The mode does not allow network creation without a valid invite", "")
		return
	}

	if result := <-Srv.Store.Team().Save(team); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		rteam := result.Data.(*model.Team)

		channel := &model.Channel{DisplayName: "Town Square", Name: "town-square", Type: model.CHANNEL_OPEN, TeamId: rteam.Id}

		if _, err := CreateChannel(c, channel, r.URL.Path, false); err != nil {
			c.Err = err
			return
		}

		if rteam.AllowValet {
			CreateValet(c, rteam)
			if c.Err != nil {
				return
			}
		}

		w.Write([]byte(rteam.ToJson()))
	}
}
开发者ID:jvlstudio,项目名称:platform,代码行数:37,代码来源:team.go


注:本文中的github.com/mattermost/platform/model.TeamFromJson函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。