Started work on the different types of objects used
This commit is contained in:
parent
e8e4ea85ba
commit
f3514b5a42
4 changed files with 112 additions and 0 deletions
11
objects/objects.go
Normal file
11
objects/objects.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2024 mStar
|
||||
//
|
||||
// Licensed under the EUPL, Version 1.2
|
||||
//
|
||||
// You may not use this work except in compliance with the Licence.
|
||||
// You should have received a copy of the Licence along with this work. If not, see:
|
||||
// <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>.
|
||||
// See the Licence for the specific language governing permissions and limitations under the Licence.
|
||||
//
|
||||
|
||||
package objects
|
14
objects/person.go
Normal file
14
objects/person.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) 2024 mStar
|
||||
//
|
||||
// Licensed under the EUPL, Version 1.2
|
||||
//
|
||||
// You may not use this work except in compliance with the Licence.
|
||||
// You should have received a copy of the Licence along with this work. If not, see:
|
||||
// <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>.
|
||||
// See the Licence for the specific language governing permissions and limitations under the Licence.
|
||||
//
|
||||
|
||||
package objects
|
||||
|
||||
type Person struct {
|
||||
}
|
59
storage/db_types.go
Normal file
59
storage/db_types.go
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Copyright (c) 2024 mStar
|
||||
//
|
||||
// Licensed under the EUPL, Version 1.2
|
||||
//
|
||||
// You may not use this work except in compliance with the Licence.
|
||||
// You should have received a copy of the Licence along with this work. If not, see:
|
||||
// <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>.
|
||||
// See the Licence for the specific language governing permissions and limitations under the Licence.
|
||||
//
|
||||
|
||||
package storage
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"net/mail"
|
||||
"net/url"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type personDB struct {
|
||||
gorm.Model // Includes primary key (uid) as well as various time info
|
||||
|
||||
// Public data
|
||||
|
||||
uid string
|
||||
name string
|
||||
instance url.URL
|
||||
local bool
|
||||
publicKey string
|
||||
|
||||
// Private data, set if local == true
|
||||
|
||||
mail *mail.Address
|
||||
pwHash *string
|
||||
inbox url.URL
|
||||
privateKey *rsa.PrivateKey
|
||||
following []url.URL
|
||||
followers []url.URL
|
||||
}
|
||||
|
||||
type noteDB struct {
|
||||
gorm.Model // Includes primary key (uid) as well as various time info
|
||||
|
||||
// Public data
|
||||
|
||||
uid string
|
||||
content string
|
||||
creator url.URL
|
||||
instance url.URL
|
||||
local bool
|
||||
tags []string
|
||||
repliesTo *url.URL
|
||||
deliverTo []url.URL
|
||||
|
||||
// Private data
|
||||
|
||||
// None yet
|
||||
}
|
28
storage/storage.go
Normal file
28
storage/storage.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2024 mStar
|
||||
//
|
||||
// Licensed under the EUPL, Version 1.2
|
||||
//
|
||||
// You may not use this work except in compliance with the Licence.
|
||||
// You should have received a copy of the Licence along with this work. If not, see:
|
||||
// <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>.
|
||||
// See the Licence for the specific language governing permissions and limitations under the Licence.
|
||||
//
|
||||
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitlab.com/beckersam/linstrom/config"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func NewDb(cfg *config.Config) (*gorm.DB, error) {
|
||||
db, err := gorm.Open(postgres.Open(cfg.General.DbPath))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to connect to db %s: %w", cfg.General.DbPath, err)
|
||||
}
|
||||
db.AutoMigrate(&personDB{}, ¬eDB{})
|
||||
return db, nil
|
||||
}
|
Loading…
Reference in a new issue