Add microsoft todo config and routes
This commit is contained in:
parent
9f3d898150
commit
a45e190092
|
@ -197,6 +197,21 @@ migration:
|
|||
# with the code obtained from the trello api.
|
||||
# Note that the vikunja frontend expects this to end on /migrate/trello.
|
||||
redirecturl: <frontend url>/migrate/trello
|
||||
microsofttodo:
|
||||
# Wheter to enable the microsoft todo migrator or not
|
||||
enable: false
|
||||
# The client id, required for making requests to the microsoft graph api
|
||||
# See https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app#register-an-application
|
||||
# for information about how to register your vikuinja instance.
|
||||
clientid:
|
||||
# The client secret, also required for making requests to the microsoft graph api
|
||||
clientsecret:
|
||||
# The url where clients are redirected after they authorized Vikunja to access their microsoft todo tasks.
|
||||
# This needs to match the url you entered when registering your Vikunja instance at microsoft.
|
||||
# This is usually the frontend url where the frontend then makes a request to /migration/microsoft-todo/migrate
|
||||
# with the code obtained from the microsoft graph api.
|
||||
# Note that the vikunja frontend expects this to be /migrate/microsoft-todo
|
||||
redirecturl: <frontend url>/migrate/microsoft-todo
|
||||
|
||||
avatar:
|
||||
# When using gravatar, this is the duration in seconds until a cached gravatar user avatar expires
|
||||
|
|
2
go.sum
2
go.sum
|
@ -839,8 +839,6 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt
|
|||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604=
|
||||
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f h1:aZp0e2vLN4MToVqnjNEYEtrEA8RH8U8FN1CU7JgqsPU=
|
||||
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
|
|
@ -110,17 +110,21 @@ const (
|
|||
FilesBasePath Key = `files.basepath`
|
||||
FilesMaxSize Key = `files.maxsize`
|
||||
|
||||
MigrationWunderlistEnable Key = `migration.wunderlist.enable`
|
||||
MigrationWunderlistClientID Key = `migration.wunderlist.clientid`
|
||||
MigrationWunderlistClientSecret Key = `migration.wunderlist.clientsecret`
|
||||
MigrationWunderlistRedirectURL Key = `migration.wunderlist.redirecturl`
|
||||
MigrationTodoistEnable Key = `migration.todoist.enable`
|
||||
MigrationTodoistClientID Key = `migration.todoist.clientid`
|
||||
MigrationTodoistClientSecret Key = `migration.todoist.clientsecret`
|
||||
MigrationTodoistRedirectURL Key = `migration.todoist.redirecturl`
|
||||
MigrationTrelloEnable Key = `migration.trello.enable`
|
||||
MigrationTrelloKey Key = `migration.trello.key`
|
||||
MigrationTrelloRedirectURL Key = `migration.trello.redirecturl`
|
||||
MigrationWunderlistEnable Key = `migration.wunderlist.enable`
|
||||
MigrationWunderlistClientID Key = `migration.wunderlist.clientid`
|
||||
MigrationWunderlistClientSecret Key = `migration.wunderlist.clientsecret`
|
||||
MigrationWunderlistRedirectURL Key = `migration.wunderlist.redirecturl`
|
||||
MigrationTodoistEnable Key = `migration.todoist.enable`
|
||||
MigrationTodoistClientID Key = `migration.todoist.clientid`
|
||||
MigrationTodoistClientSecret Key = `migration.todoist.clientsecret`
|
||||
MigrationTodoistRedirectURL Key = `migration.todoist.redirecturl`
|
||||
MigrationTrelloEnable Key = `migration.trello.enable`
|
||||
MigrationTrelloKey Key = `migration.trello.key`
|
||||
MigrationTrelloRedirectURL Key = `migration.trello.redirecturl`
|
||||
MigrationMicrosoftTodoEnable Key = `migration.microsofttodo.enable`
|
||||
MigrationMicrosoftTodoClientID Key = `migration.microsofttodo.clientid`
|
||||
MigrationMicrosoftTodoClientSecret Key = `migration.microsofttodo.clientsecret`
|
||||
MigrationMicrosoftTodoRedirectURL Key = `migration.microsofttodo.redirecturl`
|
||||
|
||||
CorsEnable Key = `cors.enable`
|
||||
CorsOrigins Key = `cors.origins`
|
||||
|
@ -292,6 +296,7 @@ func InitDefaultConfig() {
|
|||
MigrationWunderlistEnable.setDefault(false)
|
||||
MigrationTodoistEnable.setDefault(false)
|
||||
MigrationTrelloEnable.setDefault(false)
|
||||
MigrationMicrosoftTodoEnable.setDefault(false)
|
||||
// Avatar
|
||||
AvatarGravaterExpiration.setDefault(3600)
|
||||
// List Backgrounds
|
||||
|
@ -349,6 +354,10 @@ func InitConfig() {
|
|||
MigrationTrelloRedirectURL.Set(ServiceFrontendurl.GetString() + "migrate/trello")
|
||||
}
|
||||
|
||||
if MigrationMicrosoftTodoRedirectURL.GetString() == "" {
|
||||
MigrationMicrosoftTodoRedirectURL.Set(ServiceFrontendurl.GetString() + "migrate/microsoft-todo")
|
||||
}
|
||||
|
||||
log.Printf("Using config file: %s", viper.ConfigFileUsed())
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-2020 Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package microsoft_todo
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
)
|
||||
|
||||
type Migration struct {
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
func (m *Migration) AuthURL() string {
|
||||
return "https://login.microsoftonline.com/common/oauth2/v2.0/authorize" +
|
||||
"?client_id=" + config.MigrationMicrosoftTodoClientID.GetString() +
|
||||
"&response_type=code" +
|
||||
"&redirect_uri=" + config.MigrationMicrosoftTodoRedirectURL.GetString() +
|
||||
"&response_mode=query" +
|
||||
"&scope=tasks.read%20tasks.read.shared"
|
||||
}
|
||||
|
||||
func (m *Migration) Name() string {
|
||||
return "microsoft-todo"
|
||||
}
|
||||
|
||||
func getMicrosoftTodoData(token string) {
|
||||
}
|
||||
|
||||
func getMicrosoftGraphAuthToken(code string) (token string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Migration) Migrate(user *user.User) error {
|
||||
panic("implement me")
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
microsoft_todo "code.vikunja.io/api/pkg/modules/migration/microsoft-todo"
|
||||
"net/http"
|
||||
|
||||
"code.vikunja.io/api/pkg/modules/migration/trello"
|
||||
|
@ -121,6 +122,10 @@ func Info(c echo.Context) error {
|
|||
m := &trello.Migration{}
|
||||
info.AvailableMigrators = append(info.AvailableMigrators, m.Name())
|
||||
}
|
||||
if config.MigrationMicrosoftTodoEnable.GetBool() {
|
||||
m := µsoft_todo.Migration{}
|
||||
info.AvailableMigrators = append(info.AvailableMigrators, m.Name())
|
||||
}
|
||||
|
||||
if config.BackgroundsEnabled.GetBool() {
|
||||
if config.BackgroundsUploadEnabled.GetBool() {
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
microsoft_todo "code.vikunja.io/api/pkg/modules/migration/microsoft-todo"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -543,6 +544,16 @@ func registerAPIRoutes(a *echo.Group) {
|
|||
trelloMigrationHandler.RegisterRoutes(m)
|
||||
}
|
||||
|
||||
// Microsoft Todo
|
||||
if config.MigrationMicrosoftTodoEnable.GetBool() {
|
||||
microsoftTodoMigrationHandler := &migrationHandler.MigrationWeb{
|
||||
MigrationStruct: func() migration.Migrator {
|
||||
return µsoft_todo.Migration{}
|
||||
},
|
||||
}
|
||||
microsoftTodoMigrationHandler.RegisterRoutes(m)
|
||||
}
|
||||
|
||||
// List Backgrounds
|
||||
if config.BackgroundsEnabled.GetBool() {
|
||||
a.GET("/lists/:list/background", backgroundHandler.GetListBackground)
|
||||
|
|
Loading…
Reference in New Issue