Beispiel #1
0
func requireIEPGOwner(iepgID string) server.Handler {
	return getIEPG(iepgID, func(req *wcg.Request, iepg *pt.IEPG) response.Response {
		if iepg.Source != pt.IEPGSourceUser {
			return response.Forbidden(req)
		}
		return nil
	})
}
Beispiel #2
0
		middleware.Gate("family"),
		validateUserID,
		requireMessengeOptIn,
		server.Handler(
			func(req *wcg.Request) response.Response {
				content, err := createDailyNotificationContent(req)
				if err != nil {
					return response.InternalServerError(req, err)
				}
				err = messenger.NewMessengerClient(req).SendText(content.title + "\n" + strings.Join(content.lines, "\n"))
				if err != nil {
					req.Logger.Errorf("Failed to notify a message to messenger: %v", err)
				}
				return response.NewJSONResponse(map[string]interface{}{
					"ok": true,
				})
			},
		))

}

var requireMessengeOptIn = middleware.RequireMessengerOptIn("")

var validateUserID = server.Handler(func(req *wcg.Request) response.Response {
	if req.Param("userid") != req.User.ID() {
		req.Logger.Warnf("Invalid userid (Requested: %s, Actual: %s)", req.Param("userid"), req.User.ID())
		return response.Forbidden(req)
	}
	return nil
})