view src/usermap.coffee @ 29:34cfa565f565

replace fromESN twitter links with html <a>
author Mathias Gebbe <mgebbe@intevation.de>
date Tue, 29 Jul 2014 16:06:05 +0200
parents b90e6df48d2d
children 3e3fa35e3ce2
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
Usermap = DatabankObject.subClass("usermap")

Usermap.schema =
  pkey: "id"
  fields: [
    "user_pumpio"
    "user_ESN"
    "oauth_token"
    "extra_token"
    "created"
  ]
  indices: [
    "id"
    "user_pumpio"
    "user_ESN"
  ]

Usermap.beforeCreate = (props, callback) ->
  if not props.user_pumpio or not props.user_ESN
    callback new Error("Need 'user_pumpio' and 'user_ESN' in Usermap"), null
    return
  props.id = Usermap.key(props.user_pumpio, props.user_ESN)
  props.created = Date.now()
  callback null, props
  return

Usermap.key = (user_pumpio, user_ESN) ->
  user_pumpio + "_to_" + user_ESN

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