コード例 #1
0
ファイル: master.go プロジェクト: ducktsmt/snova-gae
func RetrieveAllAppIds(ctx appengine.Context) event.Event {
	if len(sharedAppIdItems) > 0 {
		res := new(event.RequestAppIDResponseEvent)
		res.AppIDs = make([]string, len(sharedAppIdItems))
		for i := 0; i < len(sharedAppIdItems); i++ {
			res.AppIDs[i] = sharedAppIdItems[i].AppID
		}
		return res
	}
	resev := new(event.AdminResponseEvent)
	resev.ErrorCause = "No shared appid."
	return resev
}
コード例 #2
0
ファイル: master.go プロジェクト: ducktsmt/snova-gae
func RetrieveAppIds(ctx appengine.Context) event.Event {
	ctx.Infof("Shared items length  :%d", len(sharedAppIdItems))
	for len(sharedAppIdItems) > 0 {
		res := new(event.RequestAppIDResponseEvent)
		res.AppIDs = make([]string, 1)
		index := rand.Intn(len(sharedAppIdItems))
		item := sharedAppIdItems[index]
		if !isValidSnovaSite(ctx, item.AppID) {
			unShareAppID(ctx, item.AppID, item.Email)
			continue
		}
		res.AppIDs[0] = item.AppID
		return res
	}
	resev := new(event.AdminResponseEvent)
	resev.ErrorCause = "No shared appid."
	return resev
}
コード例 #3
0
ファイル: master.go プロジェクト: ducktsmt/snova-gae
func shareAppID(ctx appengine.Context, appid, email string) event.Event {
	resev := new(event.AdminResponseEvent)
	if !isValidSnovaSite(ctx, appid) {
		resev.ErrorCause = "This AppId is not a valid snova appid."
		return resev
	}
	item := getSharedAppItem(ctx, appid)
	if nil != item {
		resev.ErrorCause = "This AppId is already shared!"
		return resev
	}
	item = new(AppIDItem)
	item.AppID = appid
	item.Email = email
	saveSharedAppItem(ctx, item)
	sendMail(ctx, email, "Thanks for sharing AppID:"+appid+"!",
		"Thank you for sharing your appid!")
	resev.Response = "Success"
	return resev
}
コード例 #4
0
ファイル: master.go プロジェクト: ducktsmt/snova-gae
func unShareAppID(ctx appengine.Context, appid, email string) event.Event {
	resev := new(event.AdminResponseEvent)
	item := getSharedAppItem(ctx, appid)
	if nil == item {
		resev.ErrorCause = "This appid is not shared before!"
		return resev
	}

	if item.Email != email && item.Email != misc.MasterAdminEmail {
		resev.ErrorCause = "The input email address is not equal the share email address."
		return resev
	}
	item = new(AppIDItem)
	item.AppID = appid
	item.Email = email
	deleteSharedAppItem(ctx, item)
	email_content := "Your appid:" + appid + " is unshared from snova master."
	if item.Email == misc.MasterAdminEmail {
		email_content = email_content + "\nWe noticied that your shared appid:" + appid + " is not a valid Snova Server AppID."
	}
	sendMail(ctx, email, "Unshared AppID:"+appid+"!", email_content)
	resev.Response = "Success"
	return resev
}