Skip to content

Instantly share code, notes, and snippets.

View bdmac's full-sized avatar

Brian McManus bdmac

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bdmac on github.
  • I am bdmac97 (https://keybase.io/bdmac97) on keybase.
  • I have a public key ASAsPlHc30b3yWGe9zbWNBu11KBPbr0gAL3GkGYEWlCOawo

To claim this, I am signing this object:

V2 Webook Documentation

Whenever a message is sent to or from a TextUs account we POST that message to your provided webhook URLs. The body of that request will contain:

{
  "timestamp":1500000000,
  "web_hook":{
 "id":1,
@bdmac
bdmac / user.js
Last active January 2, 2017 23:39
Adding the transient online property
import Ember from 'ember';
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
export default Model.extend({
...
online: attr('boolean', { defaultValue: false, transient: true }),
...
});
{{#if avatarable.photo}}
<img src="{{avatarable.photo}}"
alt="{{avatarable.name}} {{if avatarable.isDeleted (t 'avatarBubble.deleted')}} {{if avatarable.online (concat '(' (t 'avatarBubble.online') ')')}}"
title="{{avatarable.name}} {{if avatarable.isDeleted (t 'avatarBubble.deleted')}} {{if avatarable.online (concat '(' (t 'avatarBubble.online') ')')}}"
class="img-circle {{widthClass}}"
width="{{width}}"/>
{{else}}
{{avatarable.initials}}
{{/if}}
{{#if avatarable.online}}
@bdmac
bdmac / online-users.js
Created January 2, 2017 22:27
Online users component
import Ember from 'ember';
const { Component, inject, computed } = Ember;
export default Component.extend({
session: inject.service(),
// Get me all online users except myself
onlineUsers: computed.filter('session.currentBusiness.users.@each.online', function(user) {
return user.get('online') && user.get('id') != this.get('session.currentUser.id');
@bdmac
bdmac / controller.js
Last active January 2, 2017 22:55
controller.js
import Ember from 'ember';
import { Presence } from 'pyro/utils/phoenix'; // Import the Presence module from Phoenix...
const { Controller, inject, isPresent, computed, getOwner, Logger } = Ember;
export default Controller.extend({
channelManager: inject.service(), // Our existing custom ChannelManager service
init() {
this._super(...arguments);
defmodule Jeangrey.PrivateBusinessUpdatesChannel do
use Jeangrey.Web, :channel
alias Jeangrey.Presence # <- Added this alias
def join("private-business-updates:" <> id....) do
# Existing code to authorize connection omitted...
....
send(self, :after_join) # <- Added this
{:ok, socket}
....
@bdmac
bdmac / business_socket.ex
Last active January 2, 2017 22:21
web/channels/business_socket.ex
defmodule Jeangrey.BusinessSocket do
....
def connect(%{"accessToken" => access_token}, socket) do
......
{:ok, assign(socket, :user_id, user_id)
......
end
......
{
"id":"df137c55-f9f8-42ed-af3c-4dace0ec0e46",
"data":{
"checkin_satisfied":true,
"arrival_satisfied":true,
"hotel_satisfied":false,
"additional_feedback":"I don't know how I can tell you how much I love this place.\n\nYou are all amazing people and the world is a better place for having you.\n\n"
},
"created_at":"2015-03-25T12:39:13.129-07:00",
"status":"delivered",
{
"id":"0d8e2487-f8b3-4f63-84e3-7eaf189e0a1b",
"data":{
},
"created_at":"2015-03-06T10:08:53.112-08:00",
"status":"delivered",
"type":"Messages::Closed",
"category":"closed",
"compiled_template":{
"text/html":null,