Documentation ¶
Index ¶
- Variables
- func BulkAddMediaEvent(db *mongo.Database, mediaIDs []primitive.ObjectID, ...) (*mongo.BulkWriteResult, error)
- func BulkAddMediaGroup(db *mongo.Database, mediaIDs []primitive.ObjectID, ...) (*mongo.BulkWriteResult, error)
- func BulkAddTagEvent(db *mongo.Database, tags []string, ids []primitive.ObjectID, permission bson.M) (*mongo.BulkWriteResult, error)
- func BulkAddTagMedia(db *mongo.Database, tags []string, ids []primitive.ObjectID, permission bson.M) (*mongo.BulkWriteResult, error)
- func CloseSession(w *http.ResponseWriter, r *http.Request)
- func DecodeTagStringRequest(w http.ResponseWriter, r *http.Request, t string) (string, int)
- func DecodeTagStringsRequest(w http.ResponseWriter, r *http.Request, t []string) ([]string, int)
- func HashPassword(password string) (hashedPassword string)
- func Logger(inner http.Handler, name string) http.Handler
- func MatchesBcrypt(password string, hash string) error
- func ParseIDs(ids []string) ([]primitive.ObjectID, error)
- func ReadSessionCookie(w *http.ResponseWriter, r *http.Request) string
- func RemoveString(s []string, r string) []string
- func SetSessionCookie(w *http.ResponseWriter, r *http.Request, session *Session)
- func UniqueStrings(slice []string) []string
- func VerifyTag(db *mongo.Database, tag string) (string, error)
- func VerifyTags(db *mongo.Database, tags []string) ([]string, error)
- type App
- func (a *App) AddCommentByMediaID(w http.ResponseWriter, r *http.Request)
- func (a *App) AddDescriptionByMediaID(w http.ResponseWriter, r *http.Request)
- func (a *App) AddEvent(w http.ResponseWriter, r *http.Request)
- func (a *App) AddIPFSNodeByUsername(w http.ResponseWriter, r *http.Request)
- func (a *App) AddMedia(w http.ResponseWriter, r *http.Request)
- func (a *App) AddNode(w http.ResponseWriter, r *http.Request)
- func (a *App) AddTag(w http.ResponseWriter, r *http.Request)
- func (a *App) AddTagByMediaID(w http.ResponseWriter, r *http.Request)
- func (a *App) AddTagsByMediaID(w http.ResponseWriter, r *http.Request)
- func (a *App) AddTimestampByMediaID(w http.ResponseWriter, r *http.Request)
- func (a *App) AddTitleByMediaID(w http.ResponseWriter, r *http.Request)
- func (a *App) AddUserGroup(w http.ResponseWriter, r *http.Request)
- func (a *App) AddUserGroupsByMediaID(w http.ResponseWriter, r *http.Request)
- func (a *App) AddUserToUserGroupByID(w http.ResponseWriter, r *http.Request)
- func (a *App) AddUsersToUserGroupByID(w http.ResponseWriter, r *http.Request)
- func (a *App) Authenticate(h http.Handler, logout bool) http.Handler
- func (a *App) AuthenticateNode(w http.ResponseWriter, r *http.Request)
- func (a *App) Connect()
- func (a *App) CreateUser(w http.ResponseWriter, r *http.Request)
- func (a *App) DeleteEventByID(w http.ResponseWriter, r *http.Request)
- func (a *App) DeleteMediaByID(w http.ResponseWriter, r *http.Request)
- func (a *App) DeleteNodeByID(w http.ResponseWriter, r *http.Request)
- func (a *App) DeleteTagByID(w http.ResponseWriter, r *http.Request)
- func (a *App) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (a *App) DeleteUserGroupByID(w http.ResponseWriter, r *http.Request)
- func (a *App) GenerateInvite(w http.ResponseWriter, r *http.Request)
- func (a *App) GetEventByID(w http.ResponseWriter, r *http.Request)
- func (a *App) GetEvents(w http.ResponseWriter, r *http.Request)
- func (a *App) GetEventsByName(w http.ResponseWriter, r *http.Request)
- func (a *App) GetIPFSNodesByUsername(w http.ResponseWriter, r *http.Request)
- func (a *App) GetMedia(w http.ResponseWriter, r *http.Request)
- func (a *App) GetMediaByHash(w http.ResponseWriter, r *http.Request)
- func (a *App) GetMediaByID(w http.ResponseWriter, r *http.Request)
- func (a *App) GetMediaByIDs(w http.ResponseWriter, r *http.Request)
- func (a *App) GetNodeByID(w http.ResponseWriter, r *http.Request)
- func (a *App) GetNodes(w http.ResponseWriter, r *http.Request)
- func (a *App) GetSettingsByUsername(w http.ResponseWriter, r *http.Request)
- func (a *App) GetTagByID(w http.ResponseWriter, r *http.Request)
- func (a *App) GetTags(w http.ResponseWriter, r *http.Request)
- func (a *App) GetTagsByName(w http.ResponseWriter, r *http.Request)
- func (a *App) GetUserByUsername(w http.ResponseWriter, r *http.Request)
- func (a *App) GetUserGroupByID(w http.ResponseWriter, r *http.Request)
- func (a *App) GetUserGroups(w http.ResponseWriter, r *http.Request)
- func (a *App) GetUserGroupsByName(w http.ResponseWriter, r *http.Request)
- func (a *App) Index(w http.ResponseWriter, r *http.Request)
- func (a *App) Initialize(config models.APIGatewayConfig)
- func (a *App) InitializeRoutes()
- func (a *App) LoginUser(w http.ResponseWriter, r *http.Request)
- func (a *App) LogoutUser(w http.ResponseWriter, r *http.Request)
- func (a *App) MapEventsToMedia(w http.ResponseWriter, r *http.Request)
- func (a *App) MapGroupsToMedia(w http.ResponseWriter, r *http.Request)
- func (a *App) MapTagsToEvents(w http.ResponseWriter, r *http.Request)
- func (a *App) MapTagsToMedia(w http.ResponseWriter, r *http.Request)
- func (a *App) NewSession(user User) *Session
- func (a *App) RemoveUserFromUserGroupByID(w http.ResponseWriter, r *http.Request)
- func (a *App) RemoveUsersFromUserGroupByID(w http.ResponseWriter, r *http.Request)
- func (a *App) Run(addr string)
- func (a *App) UpdateEventByID(w http.ResponseWriter, r *http.Request)
- func (a *App) UpdateMediaByHash(w http.ResponseWriter, r *http.Request)
- func (a *App) UpdateMediaByID(w http.ResponseWriter, r *http.Request)
- func (a *App) UpdateNodeByID(w http.ResponseWriter, r *http.Request)
- func (a *App) UpdateTagByID(w http.ResponseWriter, r *http.Request)
- func (a *App) UpdateUser(w http.ResponseWriter, r *http.Request)
- func (a *App) UpdateUserGroupByID(w http.ResponseWriter, r *http.Request)
- func (a *App) UploadMedia(w http.ResponseWriter, r *http.Request)
- type Comment
- type DBConnection
- type Event
- func (e *Event) AddEvent(db *mongo.Database) (*mongo.InsertOneResult, error)
- func (e *Event) DeleteEvent(db *mongo.Database) (*mongo.DeleteResult, error)
- func (e *Event) GetEvent(db *mongo.Database, permission bson.M) error
- func (e *Event) GetEventCreate(db *mongo.Database, permission bson.M, creator string) error
- func (e *Event) UpdateEvent(db *mongo.Database, ue Event, permission bson.M) (*mongo.UpdateResult, error)
- func (e *Event) VerifyEvent(db *mongo.Database) error
- type IPFSNode
- type Invite
- func (i *Invite) FindID(db *mongo.Database) error
- func (i *Invite) FindToken(db *mongo.Database) error
- func (i *Invite) Init(db *mongo.Database, validity int) (*mongo.InsertOneResult, error)
- func (i *Invite) Invalidate(db *mongo.Database) error
- func (i *Invite) Revalidate(db *mongo.Database, validity int) error
- type Media
- func DecodeMediaRequest(w http.ResponseWriter, r *http.Request, m Media) (Media, int)
- func DecodeMediasRequest(w http.ResponseWriter, r *http.Request) ([]Media, int)
- func GetAllMedia(db *mongo.Database) ([]Media, error)
- func GetMediaByIDs(db *mongo.Database, ids []primitive.ObjectID, permission bson.M) ([]Media, error)
- func GetMediaPage(db *mongo.Database, query MediaQuery, permission bson.M) ([]Media, error)
- func (m *Media) AddMedia(db *mongo.Database) (*mongo.InsertOneResult, error)
- func (m *Media) AddTag(db *mongo.Database, t string) error
- func (m *Media) AddTags(db *mongo.Database, tags []string) error
- func (m *Media) AddUserGroups(db *mongo.Database, ugIDs []primitive.ObjectID) error
- func (m *Media) DeleteMedia(db *mongo.Database) (*mongo.DeleteResult, error)
- func (m *Media) GetMedia(db *mongo.Database, permission bson.M) error
- func (m *Media) Save(db *mongo.Database) error
- func (m *Media) UpdateMedia(db *mongo.Database, um Media) error
- type MediaEventMap
- type MediaGroupMap
- type MediaQuery
- type Node
- func (e *Node) AddNode(db *mongo.Database) (*mongo.InsertOneResult, error)
- func (e *Node) DeleteNode(db *mongo.Database) (*mongo.DeleteResult, error)
- func (e *Node) GetNode(db *mongo.Database, permission bson.M) error
- func (e *Node) UpdateNode(db *mongo.Database, ue Node, permission bson.M) (*mongo.UpdateResult, error)
- func (e *Node) VerifyNode(db *mongo.Database) error
- type Session
- type Settings
- type Tag
- func (t *Tag) AddTag(db *mongo.Database) (*mongo.InsertOneResult, error)
- func (t *Tag) DeleteTag(db *mongo.Database) (*mongo.DeleteResult, error)
- func (t *Tag) GetIDCreate(db *mongo.Database) error
- func (t *Tag) GetTag(db *mongo.Database) error
- func (t *Tag) GetTagByName(db *mongo.Database) error
- func (t *Tag) UpdateTag(db *mongo.Database, ut Tag) (*mongo.UpdateResult, error)
- type TagEventMap
- type TagMediaMap
- type User
- func (u *User) AddIPFSNode(ipfs IPFSNode) error
- func (u *User) CreateUser(db *mongo.Database) (*mongo.InsertOneResult, error)
- func (u *User) DeleteUser(db *mongo.Database) (*mongo.DeleteResult, error)
- func (u *User) Exists(db *mongo.Database) bool
- func (u *User) GetUser(db *mongo.Database) error
- func (u *User) Save(db *mongo.Database) error
- func (u *User) UpdateUser(db *mongo.Database, uu User) (*mongo.UpdateResult, error)
- type UserGroup
- func DecodeUserGroupRequest(w http.ResponseWriter, r *http.Request, ug UserGroup) (UserGroup, int)
- func DecodeUserGroupsRequest(w http.ResponseWriter, r *http.Request, ugs []UserGroup) ([]UserGroup, int)
- func GetUserGroups(db *mongo.Database, user string) ([]UserGroup, error)
- func GetUserGroupsByIDs(db *mongo.Database, ids []primitive.ObjectID) ([]UserGroup, error)
- func GetUserGroupsByKeyword(db *mongo.Database, keyword string, limit int64) ([]UserGroup, error)
- func (ug *UserGroup) AddUserGroup(db *mongo.Database, skipVerify bool) (*mongo.InsertOneResult, error)
- func (ug *UserGroup) DeleteUserGroup(db *mongo.Database) (*mongo.DeleteResult, error)
- func (ug *UserGroup) GetUserGroup(db *mongo.Database, permission bson.M) error
- func (ug *UserGroup) GetUserGroupAPI(w http.ResponseWriter, db *mongo.Database) int
- func (ug *UserGroup) Save(db *mongo.Database, skipVerify bool) error
- func (ug *UserGroup) UpdateUserGroup(db *mongo.Database, uug UserGroup, skipVerify bool) (*mongo.UpdateResult, error)
- func (ug *UserGroup) Verify(db *mongo.Database) error
Constants ¶
This section is empty.
Variables ¶
var EventProject = bson.M{
"id": 1,
"title": 1,
"description": 1,
"comments": 1,
"creator": 1,
"groups": 1,
"timestampCreation": 1,
"timestampStart": 1,
"timestampEnd": 1,
"url": 1,
"urlThumb": 1,
}
EventProject is a bson representation of the event object
var IPFSNodeProject = bson.M{
"title": 1,
"username": 1,
"password": 1,
"address": 1,
"ipfsApiPort": 1,
"ipfsApiUrl": 1,
"ipfsGateway": 1,
}
IPFSNodeProject is a bson representation of the ipfs-node setting object
var MediaProject = bson.M{ "_id": 1, "sha1": 1, "title": 1, "description": 1, "comments": 1, "creator": 1, "events": 1, "timestamp": 1, "timestampUpload": 1, "url": 1, "urlThumb": 1, "type": 1, "format": 1, "contentType": 1, "tags": 1, "users": UserProject, "groups": UserGroupProject, "nodes": NodeProject, }
MediaProject is a bson representation of the $project aggregation for mongodb
var NodeProject = bson.M{
"id": 1,
"title": 1,
"creator": 1,
"type": 1,
"groups": 1,
"url": 1,
}
NodeProject is a bson representation of the ipfs-node setting object
var Sessions = []*Session{}
Sessions is a map of token/session strings for authenticated users
var SettingsProject = bson.M{ "ipfsNodes": IPFSNodeProject, }
SettingsProject is a bson representation of the settings object
var UserGroupProject = bson.M{
"_id": 1,
"title": 1,
"creator": 1,
"users": 1,
}
UserGroupProject is a bson representation of a user group
var UserProject = bson.M{
"username": 1,
"firstName": 1,
"lastName": 1,
"urlImage": 1,
}
UserProject is a bson representation of the user object
var UserSettingsProject = bson.M{ "settings": SettingsProject, }
Functions ¶
func BulkAddMediaEvent ¶
func BulkAddMediaEvent(db *mongo.Database, mediaIDs []primitive.ObjectID, eventIDs []primitive.ObjectID, permission bson.M) (*mongo.BulkWriteResult, error)
BulkAddMediaEvent bulk operates an add events to many media ids
func BulkAddMediaGroup ¶
func BulkAddMediaGroup(db *mongo.Database, mediaIDs []primitive.ObjectID, groupIDs []primitive.ObjectID, permission bson.M) (*mongo.BulkWriteResult, error)
BulkAddMediaGroup bulk operates an adds groups to many media ids
func BulkAddTagEvent ¶
func BulkAddTagEvent(db *mongo.Database, tags []string, ids []primitive.ObjectID, permission bson.M) (*mongo.BulkWriteResult, error)
BulkAddTagEvent bulk operates a tag slice to many media ids
func BulkAddTagMedia ¶
func BulkAddTagMedia(db *mongo.Database, tags []string, ids []primitive.ObjectID, permission bson.M) (*mongo.BulkWriteResult, error)
BulkAddTagMedia bulk operates an add Tags to many media ids
func CloseSession ¶
func CloseSession(w *http.ResponseWriter, r *http.Request)
CloseSession deletes the token/session pair from cache and lets the cookie expire
func DecodeTagStringRequest ¶
DecodeTagStringRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error
func DecodeTagStringsRequest ¶
DecodeTagStringsRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
func HashPassword ¶
HashPassword hashes the passed passwort using bcrypt
func MatchesBcrypt ¶
MatchesBcrypt verifies, that a given string is equal to a encrypted string
func ReadSessionCookie ¶
func ReadSessionCookie(w *http.ResponseWriter, r *http.Request) string
ReadSessionCookie reads the stoken cookie from the request and returns the value
func RemoveString ¶
RemoveString removes a given string from a given slice
func SetSessionCookie ¶
func SetSessionCookie(w *http.ResponseWriter, r *http.Request, session *Session)
SetSessionCookie renews the session attributes and adds the token to the cookie
func UniqueStrings ¶
UniqueStrings removes all duplicates from a string slice and returns the result
Types ¶
type App ¶
type App struct { Router *mux.Router DB *mongo.Database Config *m.APIGatewayConfig Nodes []Node // stores all authenticated nodes }
App struct to maintain database connection and router
func (*App) AddCommentByMediaID ¶
func (a *App) AddCommentByMediaID(w http.ResponseWriter, r *http.Request)
AddCommentByMediaID appends a comment to the specified media
func (*App) AddDescriptionByMediaID ¶
func (a *App) AddDescriptionByMediaID(w http.ResponseWriter, r *http.Request)
AddDescriptionByMediaID adds the description to the media
func (*App) AddEvent ¶
func (a *App) AddEvent(w http.ResponseWriter, r *http.Request)
AddEvent handles the webrequest for Event creation
func (*App) AddIPFSNodeByUsername ¶
func (a *App) AddIPFSNodeByUsername(w http.ResponseWriter, r *http.Request)
AddIPFSNodeByUser adds an ipfs-node setting to the users settings
func (*App) AddMedia ¶
func (a *App) AddMedia(w http.ResponseWriter, r *http.Request)
AddMedia handles the webrequest for Media creation
func (*App) AddNode ¶
func (a *App) AddNode(w http.ResponseWriter, r *http.Request)
AddNode handles the webrequest for Node creation
func (*App) AddTag ¶
func (a *App) AddTag(w http.ResponseWriter, r *http.Request)
AddTag handles the webrequest for Tag creation
func (*App) AddTagByMediaID ¶
func (a *App) AddTagByMediaID(w http.ResponseWriter, r *http.Request)
AddTagByMediaID appends a tag to the specified media creates a new tag if not in the tag document
func (*App) AddTagsByMediaID ¶
func (a *App) AddTagsByMediaID(w http.ResponseWriter, r *http.Request)
AddTagsByMediaID appends multiple tags to the specified media creates a new tag if not in the tag document
func (*App) AddTimestampByMediaID ¶
func (a *App) AddTimestampByMediaID(w http.ResponseWriter, r *http.Request)
AddTimestampByMediaID adds the creation date to the media
func (*App) AddTitleByMediaID ¶
func (a *App) AddTitleByMediaID(w http.ResponseWriter, r *http.Request)
AddTitleByMediaID adds the title to the media
func (*App) AddUserGroup ¶
func (a *App) AddUserGroup(w http.ResponseWriter, r *http.Request)
AddUserGroup handles the webrequest for usergroup creation
func (*App) AddUserGroupsByMediaID ¶
func (a *App) AddUserGroupsByMediaID(w http.ResponseWriter, r *http.Request)
AddUserGroupsByMediaID appends multiple tags to the specified media creates a new tag if not in the tag document
func (*App) AddUserToUserGroupByID ¶
func (a *App) AddUserToUserGroupByID(w http.ResponseWriter, r *http.Request)
AddUserToUserGroupByID adds a User to the specified usergroup
func (*App) AddUsersToUserGroupByID ¶
func (a *App) AddUsersToUserGroupByID(w http.ResponseWriter, r *http.Request)
AddUsersToUserGroupByID adds a User to the specified usergroup
func (*App) Authenticate ¶
Authenticate is a middleware to pre-authenticate routes via the session token if logout is true, no new session token is beeing generated
func (*App) AuthenticateNode ¶
func (a *App) AuthenticateNode(w http.ResponseWriter, r *http.Request)
AuthenticateNode selects the specified node from db and verifies the psk
func (*App) CreateUser ¶
func (a *App) CreateUser(w http.ResponseWriter, r *http.Request)
CreateUser handles the webrequest for user creation
func (*App) DeleteEventByID ¶
func (a *App) DeleteEventByID(w http.ResponseWriter, r *http.Request)
DeleteEventByID handles the webrequest for Event deletion
func (*App) DeleteMediaByID ¶
func (a *App) DeleteMediaByID(w http.ResponseWriter, r *http.Request)
DeleteMediaByID handles the webrequest for Media deletion
func (*App) DeleteNodeByID ¶
func (a *App) DeleteNodeByID(w http.ResponseWriter, r *http.Request)
DeleteNodeByID handles the webrequest for Node deletion
func (*App) DeleteTagByID ¶
func (a *App) DeleteTagByID(w http.ResponseWriter, r *http.Request)
DeleteTagByID handles the webrequest for Tag deletion
func (*App) DeleteUser ¶
func (a *App) DeleteUser(w http.ResponseWriter, r *http.Request)
DeleteUser handles the webrequest for user deletion
func (*App) DeleteUserGroupByID ¶
func (a *App) DeleteUserGroupByID(w http.ResponseWriter, r *http.Request)
DeleteUserGroupByID handles the webrequest for usergroup deletion
func (*App) GenerateInvite ¶
func (a *App) GenerateInvite(w http.ResponseWriter, r *http.Request)
GenerateInvite handles the webrequest for creating a new invite
func (*App) GetEventByID ¶
func (a *App) GetEventByID(w http.ResponseWriter, r *http.Request)
GetEventByID handles the webrequest for receiving Event model by id
func (*App) GetEvents ¶
func (a *App) GetEvents(w http.ResponseWriter, r *http.Request)
GetEvents handles the webrequest for receiving all events
func (*App) GetEventsByName ¶
func (a *App) GetEventsByName(w http.ResponseWriter, r *http.Request)
GetEventsByName returns available Events by their name, starting with
func (*App) GetIPFSNodesByUsername ¶
func (a *App) GetIPFSNodesByUsername(w http.ResponseWriter, r *http.Request)
GetIPFSNodesByUsername returns all IPFSNodes for the current user
func (*App) GetMedia ¶
func (a *App) GetMedia(w http.ResponseWriter, r *http.Request)
GetMedia handles the webrequest for receiving all media
func (*App) GetMediaByHash ¶
func (a *App) GetMediaByHash(w http.ResponseWriter, r *http.Request)
GetMediaByHash Handles the webrequest for receiving Media model by ipfs hash and mongo id
func (*App) GetMediaByID ¶
func (a *App) GetMediaByID(w http.ResponseWriter, r *http.Request)
GetMediaByID handles the webrequest for receiving Media model by id
func (*App) GetMediaByIDs ¶
func (a *App) GetMediaByIDs(w http.ResponseWriter, r *http.Request)
GetMediaByIDs handles the webrequest for receiving Media models by ids
func (*App) GetNodeByID ¶
func (a *App) GetNodeByID(w http.ResponseWriter, r *http.Request)
GetNodeByID handles the webrequest for receiving Node model by id
func (*App) GetNodes ¶
func (a *App) GetNodes(w http.ResponseWriter, r *http.Request)
GetNodes handles the webrequest for receiving all nodes
func (*App) GetSettingsByUsername ¶
func (a *App) GetSettingsByUsername(w http.ResponseWriter, r *http.Request)
func (*App) GetTagByID ¶
func (a *App) GetTagByID(w http.ResponseWriter, r *http.Request)
GetTagByID handles the webrequest for receiving Tag model by id
func (*App) GetTags ¶
func (a *App) GetTags(w http.ResponseWriter, r *http.Request)
GetTags returns all Tags available
func (*App) GetTagsByName ¶
func (a *App) GetTagsByName(w http.ResponseWriter, r *http.Request)
GetTagsByName returns available Tags by their name, starting with
func (*App) GetUserByUsername ¶
func (a *App) GetUserByUsername(w http.ResponseWriter, r *http.Request)
GetUserByUsername handles the webrequest for receiving user model by username
func (*App) GetUserGroupByID ¶
func (a *App) GetUserGroupByID(w http.ResponseWriter, r *http.Request)
GetUserGroupByID handles the webrequest for receiving usergroup model by id
func (*App) GetUserGroups ¶
func (a *App) GetUserGroups(w http.ResponseWriter, r *http.Request)
GetUserGroups returns all groups, the current user is assigned to
func (*App) GetUserGroupsByName ¶
func (a *App) GetUserGroupsByName(w http.ResponseWriter, r *http.Request)
GetUserGroupsByName returns available Tags by their name, starting with
func (*App) Initialize ¶
func (a *App) Initialize(config models.APIGatewayConfig)
Initialize initializes application related content - mongodb connection initialization - router initialization
func (*App) InitializeRoutes ¶
func (a *App) InitializeRoutes()
InitializeRoutes initializes all the available webroutes
func (*App) LoginUser ¶
func (a *App) LoginUser(w http.ResponseWriter, r *http.Request)
LoginUser Handles the webrequest for logging the user in
func (*App) LogoutUser ¶
func (a *App) LogoutUser(w http.ResponseWriter, r *http.Request)
LogoutUser handles the webrequest for logging the user out
func (*App) MapEventsToMedia ¶
func (a *App) MapEventsToMedia(w http.ResponseWriter, r *http.Request)
MapEventsToMedia maps an media slice to each event entry
func (*App) MapGroupsToMedia ¶
func (a *App) MapGroupsToMedia(w http.ResponseWriter, r *http.Request)
MapGroupsToMedia maps an media slice to each event entry
func (*App) MapTagsToEvents ¶
func (a *App) MapTagsToEvents(w http.ResponseWriter, r *http.Request)
MapTagsToEvents maps a slice of Tags to a slice of events
func (*App) MapTagsToMedia ¶
func (a *App) MapTagsToMedia(w http.ResponseWriter, r *http.Request)
MapTagsToMedia adds a list of tags to a list of media
func (*App) NewSession ¶
NewSession initializes a new Session (if not exists) for the passed user otherwise it updates the token
func (*App) RemoveUserFromUserGroupByID ¶
func (a *App) RemoveUserFromUserGroupByID(w http.ResponseWriter, r *http.Request)
RemoveUserFromUserGroupByID adds a User to the specified usergroup
func (*App) RemoveUsersFromUserGroupByID ¶
func (a *App) RemoveUsersFromUserGroupByID(w http.ResponseWriter, r *http.Request)
RemoveUsersFromUserGroupByID adds a User to the specified usergroup
func (*App) Run ¶
Run starts the application on the passed address with the inherited router WARN: router must be initialized first
func (*App) UpdateEventByID ¶
func (a *App) UpdateEventByID(w http.ResponseWriter, r *http.Request)
UpdateEventByID handles the webrequest for updating the Event with the passed request body
func (*App) UpdateMediaByHash ¶
func (a *App) UpdateMediaByHash(w http.ResponseWriter, r *http.Request)
UpdateMediaByHash handles the webrequest for updating the Media with the passed request body
func (*App) UpdateMediaByID ¶
func (a *App) UpdateMediaByID(w http.ResponseWriter, r *http.Request)
UpdateMediaByID handles the webrequest for updating the Media with the passed request body
func (*App) UpdateNodeByID ¶
func (a *App) UpdateNodeByID(w http.ResponseWriter, r *http.Request)
UpdateNodeByID handles the webrequest for updating the Node with the passed request body
func (*App) UpdateTagByID ¶
func (a *App) UpdateTagByID(w http.ResponseWriter, r *http.Request)
UpdateTagByID handles the webrequest for updating the Tag with the passed request body
func (*App) UpdateUser ¶
func (a *App) UpdateUser(w http.ResponseWriter, r *http.Request)
UpdateUser handles the webrequest for updating the user with the passed request body
func (*App) UpdateUserGroupByID ¶
func (a *App) UpdateUserGroupByID(w http.ResponseWriter, r *http.Request)
UpdateUserGroupByID handles the webrequest for updating the usergroup with the passed request body
func (*App) UploadMedia ¶
func (a *App) UploadMedia(w http.ResponseWriter, r *http.Request)
UploadMedia handles the webrequest for uploading a file to the api
type Comment ¶
type Comment struct { Timestamp int64 `json:"timestamp,omitempty"` Username string `json:"username,omitempty"` Comment string `json:"comment,omitempty"` }
Comment type that is beeing referenced by multiple other types
func DecodeCommentRequest ¶
DecodeCommentRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error
func DecodeCommentsRequest ¶
DecodeCommentsRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
func (*Comment) AddMetadata ¶
AddMetadata sets the passed username and the current timestamp for this comment
type DBConnection ¶
type DBConnection struct { Col *mongo.Collection Ctx context.Context Cancel context.CancelFunc }
DBConnection holds information about the collection and the context
type Event ¶
type Event struct { ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` Title string `json:"title,omitempty" bson:"title,omitempty"` Description string `json:"description,omitempty" bson:"description,omitempty"` Comments []*Comment `json:"comments,omitempty" bson:"comments,omitempty"` Creator string `json:"creator,omitempty" bson:"creator,omitempty"` Groups []primitive.ObjectID `json:"groups,omitempty" bson:"groups,omitempty"` TimestampCreation int64 `json:"timestampCreation,omitempty" bson:"timestampCreation,omitempty"` TimestampStart int64 `json:"timestampStart,omitempty" bson:"timestampStart,omitempty"` TimestampEnd int64 `json:"timestampEnd,omitempty" bson:"timestampEnd,omitempty"` URL string `json:"url,omitempty" bson:"url,omitempty"` URLThumb string `json:"urlThumb,omitempty" bson:"urlThumb,omitempty"` }
Event holds comments, media and the information about the the event
func GetAllEvents ¶
GetAllEvents selects all Events from the mongodb
func GetEventsByIDs ¶
func GetEventsByIDs(db *mongo.Database, ids []primitive.ObjectID, permission bson.M) ([]Event, error)
GetEventsByIDs selects multiple Media Documents for the passed ids. verifies the reading permissions
func GetEventsByKeyword ¶
func GetEventsByKeyword(db *mongo.Database, permission bson.M, keyword string, limit int64) ([]Event, error)
GetEventsByKeyword returns the topmost events that are starting with the keyword
func (*Event) DeleteEvent ¶
DeleteEvent deletes the model from the mongodb
func (*Event) GetEventCreate ¶
GetEventCreate selects the passed event from database -> creates if not exist
type IPFSNode ¶
type IPFSNode struct { Title string `json:"title" bson:"title"` Username string `json:"username" bson:"username"` Password string `json:"password,omitempty" bson:"password,omitempty"` Address string `json:"address,omitempty" bson:"address,omitempty"` IPFSAPIPort int `json:"ipfsApiPort,omitempty" bson:"ipfsApiPort,omitempty"` IPFSAPIURL string `json:"ipfsApiUrl,omitempty" bson:"ipfsApiUrl,omitempty"` IPFSGateway string `json:"ipfsGateway,omitempty" bson:"ipfsGateway,omitempty"` }
IPFSNode stores all relevant information about an additional node for uploads
func DecodeIPFSNodeRequest ¶
DecodeIPFSNodeRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error
type Invite ¶
type Invite struct { ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` Token string `json:"token,omitempty" bson:"token,omitempty"` Until int64 `json:"until,omitempty" bson:"until,omitempty"` Used bool `json:"used,omitempty" bson:"used,omitempty"` }
Invite represents the database entry for the tokens
func (*Invite) Invalidate ¶
Invalidate verifies that the token is in the database and is valid. If the token is valid, it sets it's used state to used.
type Media ¶
type Media struct { ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` Sha1 string `json:"sha1,omitempty" bson:"sha1,omitempty"` ThumbnailSha1 string `json:"thumbnailSha1,omitempty" bson:"thumbnailSha1,omitempty"` Title string `json:"title,omitempty" bson:"title,omitempty"` Description string `json:"description,omitempty" bson:"description,omitempty"` Comments []*Comment `json:"comments,omitempty" bson:"comments,omitempty"` Creator string `json:"creator,omitempty" bson:"creator,omitempty"` Events []primitive.ObjectID `json:"events,omitempty" bson:"events,omitempty"` GroupIDs []primitive.ObjectID `json:"groupIDs,omitempty" bson:"groupIDs,omitempty"` Timestamp int64 `json:"timestamp,omitempty" bson:"timestamp,omitempty"` TimestampUpload int64 `json:"timestampUpload,omitempty" bson:"timestampUpload,omitempty"` URL string `json:"url,omitempty" bson:"url,omitempty"` URLThumb string `json:"urlThumb,omitempty" bson:"urlThumb,omitempty"` Type string `json:"type,omitempty" bson:"type,omitempty"` Format string `json:"format,omitempty" bson:"format,omitempty"` ContentType string `json:"contentType,omitempty" bson:"contentType,omitempty"` Tags []string `json:"tags,omitempty" bson:"tags,omitempty"` NodeIDs []primitive.ObjectID `json:"nodeIDs,omitempty" bson:"nodeIDs,omitempty"` Users []User `json:"users,omitempty"` Groups []UserGroup `json:"groups,omitempty"` Nodes []Node `json:"nodes,omitempty"` }
Media holds all information about the item
func DecodeMediaRequest ¶
DecodeMediaRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error
func DecodeMediasRequest ¶
DecodeMediasRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
func GetAllMedia ¶
GetAllMedia selects all Media from the mongodb
func GetMediaByIDs ¶
func GetMediaByIDs(db *mongo.Database, ids []primitive.ObjectID, permission bson.M) ([]Media, error)
GetMediaByIDs selects multiple Media Documents for the passed ids. verifies the reading permissions
func GetMediaPage ¶
GetMediaPage returns the requested page after a specific id
func (*Media) AddTag ¶
AddTag adds a tag to the mapped tag set (ignores duplicates) Overrides the current model instance
func (*Media) AddTags ¶
AddTags adds a tag array to the mapped tag set (ignores duplicates) Overrides the current model instance
func (*Media) AddUserGroups ¶
AddUserGroups adds an array of primitive.ObjectID (of a usergroup) to the mapped usergroup set (ignores duplicates) Overrides the current model instance
func (*Media) DeleteMedia ¶
DeleteMedia deletes the model from the mongodb
type MediaEventMap ¶
type MediaEventMap struct { Events []Event `json:"events,omitempty"` MediaIDs []string `json:"mediaIDs,omitempty"` }
MediaEventMap is used to map an array of events to an array of media
func DecodeMediaEventMapRequest ¶
func DecodeMediaEventMapRequest(w http.ResponseWriter, r *http.Request) (MediaEventMap, int)
DecodeMediaEventMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
type MediaGroupMap ¶
type MediaGroupMap struct { Groups []UserGroup `json:"groups,omitempty"` MediaIDs []string `json:"mediaIDs,omitempty"` }
MediaGroupMap is used to map an array of groups to an array of media
func DecodeMediaGroupMapRequest ¶
func DecodeMediaGroupMapRequest(w http.ResponseWriter, r *http.Request) (MediaGroupMap, int)
DecodeMediaGroupMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
type MediaQuery ¶
type MediaQuery struct { After primitive.ObjectID Before primitive.ObjectID Event primitive.ObjectID Filter string From primitive.ObjectID Until primitive.ObjectID Size int ASC int16 }
MediaQuery holds query options for the media api
func (*MediaQuery) IsValid ¶
func (mq *MediaQuery) IsValid() error
IsValid validates that the passed query combination is allowed for filtering
type Node ¶
type Node struct { ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` Title string `json:"title,omitempty" bson:"title,omitempty"` Creator string `json:"creator,omitempty" bson:"creator,omitempty"` Type string `json:"type,omitempty" bson:"type,omitempty"` Secret string `json:"secret,omitempty" bson:"secret,omitempty"` Groups []primitive.ObjectID `json:"groups,omitempty" bson:"groups,omitempty"` URL string `json:"url,omitempty" bson:"url,omitempty"` }
Node holts the users and the information about the group
func GetAllNodes ¶
GetAllNodes selects all Nodes from the mongodb
func (*Node) DeleteNode ¶
DeleteNode deletes the model from the mongodb
type Session ¶
Session stores the user data, the token, the expiration of the session and the usergroups of the current user
func GetSession ¶
GetSession returns the session object for the passed token
func GetSessionByUser ¶
GetSessionByUser Returns the session for the passed user if exist
func GetSessionByUsername ¶
GetSessionByUsername returns the session for the passed username if exist
func RemoveToken ¶
RemoveToken finds the entry with the passed token and deletes it
func (*Session) RenewToken ¶
RenewToken creates a new token and resets the expiry interval
type Settings ¶
type Settings struct {
IPFSNodes []*IPFSNode `json:"ipfsNodes,omitempty" bson:"ipfsNodes,omitempty"`
}
Settings stores all user related configurations
type Tag ¶
type Tag struct { ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` Name string `json:"name,omitempty" bson:"name,omitempty"` }
Tag has a name and an ID for the reference
func DecodeTagRequest ¶
DecodeTagRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error
func DecodeTagsRequest ¶
DecodeTagsRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
func GetTagsByKeyword ¶
GetTagsByKeyword returns the topmost tags that are starting with the keyword
func (*Tag) GetIDCreate ¶
GetIDCreate searches the database for the passed tag and adds the id to the current tag. It creates a new tag document if the passed tag was not find in the database
func (*Tag) GetTagByName ¶
GetTagByName returns the specified entry from the mongodb
type TagEventMap ¶
type TagEventMap struct { Events []Event `json:"events,omitempty"` Tags []string `json:"tags,omitempty"` }
TagEventMap ist used to map an array of tags to an array of media
func DecodeTagEventMapRequest ¶
func DecodeTagEventMapRequest(w http.ResponseWriter, r *http.Request) (TagEventMap, int)
DecodeTagEventMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
type TagMediaMap ¶
type TagMediaMap struct { IDs []string `json:"ids,omitempty"` Tags []string `json:"tags,omitempty"` }
TagMediaMap ist used to map an array of tags to an array of media
func DecodeTagMediaMapRequest ¶
func DecodeTagMediaMapRequest(w http.ResponseWriter, r *http.Request) (TagMediaMap, int)
DecodeTagMediaMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
type User ¶
type User struct { Username string `json:"username" bson:"username"` FirstName string `json:"firstName,omitempty" bson:"firstName,omitempty"` LastName string `json:"lastName,omitempty" bson:"lastName,omitempty"` Password string `json:"password,omitempty" bson:"password,omitempty"` URLImage string `json:"urlImage,omitempty" bson:"urlImage,omitempty"` Token string `json:"token,omitempty"` Settings *Settings `json:"settings,omitempty" bson:"settings,omitempty"` }
User contains all information about the user
func DecodeUserRequest ¶
DecodeUserRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error
func DecodeUsersRequest ¶
DecodeUsersRequest decodes the api request into the passed user slice responds with decode error if occurs status 0 => ok || status 1 => error
func (*User) AddIPFSNode ¶
AddIPFSNode checks if the passed node struct is valid and adds it to the user
func (*User) CreateUser ¶
CreateUser creates the user model in the mongodb
func (*User) DeleteUser ¶
DeleteUser deletes the model from the mongodb
func (*User) Exists ¶
Exists checks if the user can be selected from the database Assumes false if any error occurs
func (*User) Save ¶
Save writes changes, made to the instance itself, to the database and overrides the instance with the return value from the database
func (*User) UpdateUser ¶
UpdateUser updates the record with the passed one
type UserGroup ¶
type UserGroup struct { ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` Title string `json:"title,omitempty" bson:"title,omitempty"` Creator string `json:"creator,omitempty" bson:"creator,omitempty"` Users []string `json:"users,omitempty" bson:"users,omitempty"` }
UserGroup holts the users and the information about the group
func DecodeUserGroupRequest ¶
DecodeUserGroupRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error
func DecodeUserGroupsRequest ¶
func DecodeUserGroupsRequest(w http.ResponseWriter, r *http.Request, ugs []UserGroup) ([]UserGroup, int)
DecodeUserGroupsRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
func GetUserGroups ¶
GetUserGroups returns all groups the user is part of
func GetUserGroupsByIDs ¶
GetUserGroupsByIDs returns a slice of usergroups, that are matching the given id slice
func GetUserGroupsByKeyword ¶
GetUserGroupsByKeyword returns the topmost groups that are starting with the keyword
func (*UserGroup) AddUserGroup ¶
func (ug *UserGroup) AddUserGroup(db *mongo.Database, skipVerify bool) (*mongo.InsertOneResult, error)
AddUserGroup creates the model in the mongodb
func (*UserGroup) DeleteUserGroup ¶
DeleteUserGroup deletes the model from the mongodb
func (*UserGroup) GetUserGroup ¶
GetUserGroup returns the specified entry from the mongodb
func (*UserGroup) GetUserGroupAPI ¶
GetUserGroupAPI handles possible errors during the select and writes Responses
func (*UserGroup) Save ¶
Save writes changes, made to the instance itself, to the database and overrides the instance with the return value from the database
func (*UserGroup) UpdateUserGroup ¶
func (ug *UserGroup) UpdateUserGroup(db *mongo.Database, uug UserGroup, skipVerify bool) (*mongo.UpdateResult, error)
UpdateUserGroup updates the record with the passed one
Source Files ¶
- api_comment_helper.go
- api_event.go
- api_event_helper.go
- api_infra_node.go
- api_invite.go
- api_media.go
- api_media_helper.go
- api_nodes.go
- api_tag.go
- api_tag_helper.go
- api_user.go
- api_user_helper.go
- api_usergroup.go
- api_usergroup_helper.go
- app.go
- handler_api.go
- handler_database.go
- handler_session.go
- logger.go
- model_comment.go
- model_event.go
- model_invite.go
- model_media.go
- model_media_query.go
- model_node.go
- model_session.go
- model_setting.go
- model_tag.go
- model_tag_event_map.go
- model_tag_media_map.go
- model_user.go
- model_user_group.go
- routers.go