focalboard/server/model/block.go
Harshil Sharma e0ec1c03e0
New Props: Created By, Created At, Updated By, Updated At (#583)
* Added create_at column for blocks

* Populating created by

* Added logic for storing created by

* Added GetBlock by ID to store interface

* Added creayed by and modified by properties

* Added created by and modified by properties

* Added lastmodifiedat property

* Fixed existing webapp test

* Added webapp unit tests

* Added webapp unit tests

* Added webapp unit tests

* Adding server test

* Added server tests

* Fixed a bug causing created by to be set empty

* Avodining timezone specific test behavior

* Made cypress viewport bigger to avoid out-of-viewoport issues in multiple tests

* Removed a leftover comment

* Added updated at/by in table view

* Added updated at in card view

* Fixing sort

* Fixed sorting of updated by

* Fixed existing tests

* Added table tests

* Added cardTree fix

* Fixed tests

* Removed unused import

* Update snapshots

* Added a tamper attempt test

* Removed some leftover debug code

* Removed sending creator from client

* Fixed lint error

* Fixed a build issue

* Avoided setting insert query params multiple times

* Multiple minor review fixes

* Fixed test
2021-07-08 20:06:43 +05:30

86 lines
1.8 KiB
Go

package model
import (
"encoding/json"
"io"
)
// Block is the basic data unit
// swagger:model
type Block struct {
// The id for this block
// required: true
ID string `json:"id"`
// The id for this block's parent block. Empty for root blocks
// required: false
ParentID string `json:"parentId"`
// The id for this block's root block
// required: true
RootID string `json:"rootId"`
// The id for user who created this block
// required: true
CreatedBy string `json:"createdBy"`
// The id for user who last modified this block
// required: true
ModifiedBy string `json:"modifiedBy"`
// The schema version of this block
// required: true
Schema int64 `json:"schema"`
// The block type
// required: true
Type string `json:"type"`
// The display title
// required: false
Title string `json:"title"`
// The block fields
// required: false
Fields map[string]interface{} `json:"fields"`
// The creation time
// required: true
CreateAt int64 `json:"createAt"`
// The last modified time
// required: true
UpdateAt int64 `json:"updateAt"`
// The deleted time. Set to indicate this block is deleted
// required: false
DeleteAt int64 `json:"deleteAt"`
}
// Archive is an import / export archive.
type Archive struct {
Version int64 `json:"version"`
Date int64 `json:"date"`
Blocks []Block `json:"blocks"`
}
func BlocksFromJSON(data io.Reader) []Block {
var blocks []Block
_ = json.NewDecoder(data).Decode(&blocks)
return blocks
}
// LogClone implements the `mlog.LogCloner` interface to provide a subset of Block fields for logging.
func (b Block) LogClone() interface{} {
return struct {
ID string
ParentID string
RootID string
Type string
}{
ID: b.ID,
ParentID: b.ParentID,
RootID: b.RootID,
Type: b.Type,
}
}