models.server.Ticket Class
Server Ticket model
Item Index
Methods
- addComment
- addDevice
- addFollower
- addHandler
- addRelatedUser
- addTag
- addTitle
- addVisibility
- byVisibilities static
- comments
- create
- createdAt
- deletedAt
- devices
- ensureNotification
- fetchByIdConstrained static
- fetchOrCreate
- followers
- generateSecret
- getCurrentTitle
- getDescription
- getReplyEmailAddress
- getSocketIORoom
- handlers
- hasVisibility
- initialize
- static
- isHandler
- isSame
- isSoftDeleted
- markAsRead
- relatedUsers
- removeFollower
- removeTag
- renderEmailBufferedTemplate static
- sendBufferedEmailNotifications
- sendMail
- setStatus
- softDelete
- status
- tags
- titles
- triggerUpdate
- uniqueId
- unreadComments
- updatedAt
- updateTimestamp
- visibilities
- withUnreadComments static
Properties
Methods
addComment
-
comment -
user -
[opts]
Add comment to the ticket
Parameters:
-
commentString -
usermodels.server.User | NumberCreator of the tag
-
[opts]Boolean optional-
[silent=false]Boolean optionalSet to true to disable update notifications
-
Returns:
with models.server.Comment
addDevice
-
device -
addedBy
Add device relation
Parameters:
-
devicemodels.server.Device | NumberDevice model or external id of the device
-
addedBymodels.server.User | NumberUser model or id of user who adds the device
Returns:
with models.server.Device
addFollower
-
follower -
addedBy
Add follower to a ticket. Also adds a visibility for the follower.
Parameters:
-
followermodels.server.User | NumberUser model or id of the follower
-
addedBymodels.server.User | NumberUser model or id of the user who adds the handler
Returns:
with models.server.Handler
addHandler
-
handler -
addedBy
Add handler to a ticket
Parameters:
-
handlermodels.server.User | NumberUser model or id of the handler
-
addedBymodels.server.User | NumberUser model or id of the user who adds the handler
Returns:
with models.server.Handler
addRelatedUser
-
user -
addedBy
Add related user to the ticket
Parameters:
-
usermodels.server.User | NumberUser object or id for the relation
-
addedBymodels.server.User | NumberUser model or id of user who adds the user
Returns:
with models.server.RelatedUser
addTag
-
tag -
user
Add Tag to the ticket
Parameters:
-
tagString -
usermodels.server.UserCreator of the tag
Returns:
with models.server.Tag
addTitle
-
title -
user -
[opts]
Add title to the ticket
Parameters:
-
titleString -
usermodels.server.User | NumberCreator of the tag
-
[opts]Boolean optional-
[silent=false]Boolean optionalSet to true to disable update notifications
-
Returns:
with models.server.Title
addVisibility
-
visibility -
addedBy -
[comment]
Add visibility to the ticket. If the visibility already exists for the ticket the existing visibility is returned.
Visibility strings can be accessed for example from User#getVisibilities()
Parameters:
-
visibilityStringVisibility string
-
addedBymodels.server.User | NumberUser model or id of user who adds the visibility
-
[comment]String optionalOptional comment for the visibility
Returns:
with models.server.Visibility
byVisibilities
-
visibilities
Fetch tickets by given visibilities.
Parameters:
-
visibilitiesArrayArray of visibility strings. Strings are in the form of
organisation|school|user:<entity id>.Example: "school:2"
Returns:
with models.server.Ticket models
comments
()
Bookshelf.Collection
Returns:
Bookshelf.Collection of Ticket comment models
create
-
title -
description -
createdBy -
[options]
Shortcut for creating ticket with a title and description.
Parameters:
-
titleString -
descriptionString -
createdBymodels.server.User | Number -
[options]Object optional-
[mailTransport]optionalcustom mail transport
-
Returns:
with models.server.Ticket
createdAt
()
Date
Returns:
deletedAt
()
Date
Returns:
devices
()
Bookshelf.Collection
Returns:
Bookshelf.Collection of Ticket devices
ensureNotification
-
user
Ensure notification relation for a user
Parameters:
-
usermodels.server.User | Number
Returns:
with models.server.Notification
fetchByIdConstrained
-
user -
ticketId -
options
Fetch the ticket by id with visibilities of the user
Parameters:
-
usermodels.server.User -
ticketIdNumberTicket id
-
optionsObjectOptions passed to Bookshelf fetchOne method
Returns:
With models.server.Ticket
fetchOrCreate
-
identifier
Fetch or create a model uniquely identified by the columns defined in
the identifier
Parameters:
-
identifierObjectObject of table columns
Returns:
with the model instance
followers
()
Bookshelf.Collection
Returns:
Bookshelf.Collection of Ticket followers relations
generateSecret
()
String
Generate secure random secret for email replies
Returns:
getCurrentTitle
()
String
Return the current title. Requires titles relation
Returns:
getDescription
()
String
Get description ie. the first comment
Returns:
getReplyEmailAddress
()
String
Returns:
getSocketIORoom
()
String
Returns:
handlers
()
Bookshelf.Collection
Returns:
Bookshelf.Collection of Ticket handlers
hasVisibility
-
visibility -
models
Visibility assertion helper
Parameters:
-
visibilityString -
modelsArrayArray of models.server.Visibility models
Returns:
Boolean
initialize
-
attrs -
[options.mailTransport]
Parameters:
-
attrsObjectModel attributes
-
[options.mailTransport]Object optionalcustom mail transport
isHandler
-
UNKNOWN
Returns true if the user is handler for this ticket
'handlerUsers' relation must be loaded with 'withRelated' in fetch or with Ticket#load("handlerUsers")
Parameters:
-
UNKNOWNmodels.server.User | Number
Returns:
isSame
-
other
Return true if the other object is built using the same constructor and they have the same id
Parameters:
-
otherBackbone.Model
Returns:
Boolean
isSoftDeleted
()
Boolean
Returns:
markAsRead
-
user -
[options]
Mark ticket as read
Parameters:
-
usermodels.server.User | NumberUser model or id of the user
-
[options]Object optional-
[emailOnly]Object optionalSet to true to mark as read from email
-
Returns:
with models.server.Notification
removeFollower
-
user -
removedBy
Remove user from followers
Parameters:
-
usermodels.server.User -
removedBymodels.server.User
Returns:
removeTag
-
tag -
removedBy -
[options]
Soft delete given tag
Parameters:
-
tagString -
removedBymodels.server.User | Number -
[options]Object optional-
[require=false]Boolean optionalWhen true the promise is rejected if the tag is missing
-
Returns:
renderEmailBufferedTemplate
-
context
Render buffered email update
Parameters:
-
contextObject
Returns:
sendBufferedEmailNotifications
-
user
Parameters:
-
usermodels.server.User | NumberUser model or id of the user
Returns:
sendMail
-
options
See nodemailer module docs https://github.com/andris9/Nodemailer#sending-mail
Parameters:
-
optionsObject
Returns:
setStatus
-
status -
user -
[options.force=false]
Set status of the ticket
Parameters:
-
statusString -
usermodels.server.UserCreator of the status
-
[options.force=false]Boolean optionalSet to true to skip manager validation
Returns:
models.server.Tag representing the status
softDelete
-
byUser
Set timestamp to deletedAt
Parameters:
-
byUsermodels.server.User | NumberThe user who deleted the model
Returns:
status
()
Bookshelf.Collection
Return collection containing only one models.server.Tag representing the
status of the ticket. When serialized as JSON this field will appear as
a simple string field. Example: status: "open".
Returns:
titles
()
Bookshelf.Collection
Returns:
Bookshelf.Collection of Ticket title models
triggerUpdate
-
model
Parameters:
-
modelmodels.server.BaseAny ticket relation model
Returns:
uniqueId
()
String
Returns:
unreadComments
-
user -
[options]
Get unread comments for given user. Use options.byEmail to get those
comments that have not been sent out as email.
Parameters:
-
usermodels.server.User | Numberor user id
-
[options]Options optional-
[byEmail]Options optionalget comments that are not emailed
-
Returns:
updatedAt
()
Date
Returns:
updateTimestamp
()
Bluebird.Promise
Update updatedAt column to current time. Should be called when ever a
update relation is added to the ticket
Returns:
visibilities
()
models.server.Visibility
Returns:
withUnreadComments
-
user -
[options]
Return collection of tickets that have unread comments by the user
Parameters:
-
usermodels.client.User | Number -
[options]Object optional-
[byEmail=false]Object optionalGet tickets by unsent email notifications
-
Returns:
of models.server.Ticket
Properties
_mailTransport
Object
private
nodemailer email transport object
type
String
The database table name
Virtual database field. Use .get("type") to access it.
unique_id
String
Unique id between tables.
Virtual database field. Use .get("unique_id") to access it.
