view src/fromESN.coffee @ 32:ca0b44c1a870 tip

Readme: twitter in the summary, it is best working currently.
author Bernhard Reiter <bernhard@intevation.de>
date Mon, 13 Oct 2014 13:22:17 +0200
parents b90e6df48d2d
children
line wrap: on
line source
# Copyright (C) 2014 by Intevation GmbH
# Author: Mathias Gebbe <mgebbe@intevation.de>
#
# This file is Free Software under the Apache License, Version 2.0;
# and comes with NO WARRANTY!
# See the documentation coming with pumpbridge for details.

_ = require("underscore")
async = require("async")
DatabankObject = require("databank").DatabankObject
FromESN = DatabankObject.subClass("fromESN")

FromESN.schema =
  pkey: "uid"
  fields: [
    "postid"
    "sourceUser"
    "sourcePost"
    "pumpPost"
    "recipientUser"
    "created"
    "updated"
  ]
  indices: [
    "uid"
    "postid"
    "sourceUser"
    "sourcePost"
    "pumpPost"
    "recipientUser"
  ]

FromESN.beforeCreate = (props, callback) ->
  if not props.sourcePost or not props.sourceUser
    callback new Error("Need 'sourceUser' and 'sourceUser'"), null
    return
  props.uid = FromESN.key(props.postid , props.recipientUser)
  props.created = Date.now()
  props.updated = Date.now()
  callback null, props
  return

FromESN::beforeSave = (callback) ->
  props = this
  if not props.sourcePost or not props.sourceUser
    callback new Error("Need 'sourceUser' and 'sourceUser'"), null
    return
  props.updated = Date.now()
  callback null
  return

FromESN.key = (postid, recipientUser) ->
  postid + "_to_" + recipientUser

module.exports = FromESN
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)