How to get How many unread notifications does user have on getStream?
I just need an integer value of unread notifications.
(I will call the unread notifications the main like Facebook or Instagram!)
Thanks in advance
A typical response when fetching a Notification feed is:
> notificationFeed.get().then((response) => console.log(response));
Promise { _state: 0, _onFulfilled: [], _onRejected: [] }
> { results:
[ { activities: [Array],
activity_count: 1,
actor_count: 1,
created_at: '2017-12-27T10:15:39.215550',
group: 'e325120c-eaee-11e7-97ec-1283934ff98c',
id: 'e3267b75-eaee-11e7-8080-800052f2693c.e325120c-eaee-11e7-97ec-1283934ff98c',
is_read: false,
is_seen: false,
updated_at: '2017-12-27T10:15:39.215550',
verb: 'post' } ],
next: '',
duration: '12.76ms',
unseen: 1,
unread: 1 }
The unseen and unread properties on the response indicate the number of activities in the notification feed that are marked unseen, and unread respectively.
Related
I encountered a strange mistake. I add a data that I send with Vue axios post to the database, a column of this data that is converted to JSON object with JSON.stringfy. When I try to update this line later, can I share the idea that I am having the following error? I shared SQL string below.
{
id: null,
table_id: 1425,
user_id: 15,
order_time: 1586975000253,
order_status: 1,
order: [
{
product: 8,
amount: 1,
portion: [Object],
order_time: 1586974979254,
status: 0,
desc: ''
},
{
product: 4,
amount: 1,
portion: [Object],
order_time: 1586974979707,
status: 0,
desc: ''
},
{
product: 8,
amount: 1,
portion: [Object],
order_time: 1586974980271,
status: 0,
desc: ''
}
],
corp: 'sssxx'
}
ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'order = '[{\"product\":8,\"amount\":1,\"portion\":{\"id\":1,\"title\":\"Tam Pors' at line 1
UPDATE orders SET order = '[{\\"product\\":8,\\"amount\\":1,\\"portion\\":{\\"id\\":1,\\"title\\":\\"Tam Porsiyon\\",\\"price\\":\\"25\\"},\\"order_time\\":1586974979254,\\"status\\":0,\\"desc\\":\\"\\"},{\\"product\\":4,\\"amount\\":1,\\"portion\\":{\\"id\\":1,\\"title\\":\\"Tam Porsiyon\\",\\"price\\":\\"25\\"},\\"order_time\\":1586974979707,\\"status\\":0,\\"desc\\":\\"\\"},{\\"product\\":8,\\"amount\\":1,\\"portion\\":{\\"id\\":1,\\"title\\":\\"Tam Porsiyon\\",\\"price\\":\\"25\\"},\\"order_time\\":1586974980271,\\"status\\":0,\\"desc\\":\\"\\"}]', order_status = 1 WHERE id = NULL AND table_id = 1425 and corp = 'sssxx'
The problem with your code has nothing to do with using JSON.
The word order is a reserved keyword. See https://mariadb.com/kb/en/reserved-words/ You can't use it as a column name unless you delimit it with back-ticks:
UPDATE orders SET `order` = ...whatever...
The clue in the error message is that it complained about the word order, not about anything in your JSON.
...for the right syntax to use near 'order = ...
Syntax errors show you exactly the point in your SQL syntax where the parser got confused.
Using node-recurly, I can create a subscription object and pass it to recurly.subscriptions.create call:
const subscription = {
plan_code: plan.code,
currency: 'USD',
account: {
account_code: activationCode,
first_name: billingInfo.first_name,
last_name: billingInfo.last_name,
email: billingInfo.email,
billing_info: {
token_id: paymentToken,
},
},
};
I would also like to add subscription_add_ons property, which, looking at the documentation, supposed to be an array of add-ons. I tried passing it like this:
subscription_add_ons: [
{
add_on_code: shippingMethod.servicelevel_token,
unit_amount_in_cents: parseFloat(shippingMethod.amount) * 100,
},
],
The server returned an error:
Tag <subscription_add_ons> must consist only of sub-tags named
<subscription_add_on>
I attempted this:
subscription_add_ons: [
{
subscription_add_on: {
add_on_code: shippingMethod.servicelevel_token,
unit_amount_in_cents: parseFloat(shippingMethod.amount) * 100,
},
},
],
Got back this error:
What's the proper format to pass subscription add on in this scenario?
The proper format is:
subscription_add_ons: {
subscription_add_on: [{
add_on_code: shippingMethod.servicelevel_token,
unit_amount_in_cents: parseFloat(shippingMethod.amount) * 100,
}],
},
I ended up doing this which works whether you have 1 add-on or multiple add-ons. subscription_add_ons is an array which can contain 1 or more subscription add ons. I then send over the details (along with other info) in the subscription update call. This is similar to what you attempted in your original post so I'm not sure why that didn't work for you.
details.subscription_add_ons = [
{ subscription_add_on: {add_on_code: "stream", quantity: 3} },
{ subscription_add_on: {add_on_code: "hold", quantity: 2} }
];
When using docusign inline signing api, I get event=ttl_expired frequently. I even tried using the Docusign API Explorer and the same thing happens. For every two out of three URLs that I get, I get the ttl_expired error. I checked the possible reasons given in DocuSign getRecipientView ttl_expired error but to no avail.
Is there something that I am missing here?
The truncated sample json is below. I have replaced the mail IDs & name field.
{
signers: [{
name: 'Name',
email: 'mail#example.com',
text_tabs: [
{
label: 'Name Field',
anchor_string: 'Name:',
anchor_x_offset: '100',
anchor_y_offset: '-10',
document_id: '1',
page_number: '10',
required: true,
width: 200,
height: 10
}
],
sign_here_tabs: [
{
label: 'Signature',
anchor_string: 'Signature',
anchor_x_offset: '100',
anchor_y_offset: '-20',
document_id: '1',
page_number: '10',
}
],
routing_order: 1,
embedded: true,
role_name: 'FirstRole',
clientUserId: 1
},
{
name: 'Another Name',
email: 'Anothermail#example.com',
sign_here_tabs: [
{
anchor_string: 'COMPANY:',
anchor_x_offset: '-20',
anchor_y_offset: '-20'
}
],
routing_order: 2,
embedded: false,
role_name: 'SecondRole'
}],
status: 'sent',
return_url: 'http://www.google.com',
email_subject: 'Agreement from Document',
email_body: 'Please sign the Agreement',
files: [
{
path: File.join('/', 'docusign_docs', 'Agreement.pdf'),
name: 'Agreement.pdf'
}
]
}
1) Per the other article you reference, the URL that is returned must be opened/used within 300 seconds
2) These are one time use URL's only. If you try to re-use the same URL a second+ time, it will automatically re-direct you to the landing page w/ttl_expired event.
Your design pattern must be to request the signing url from DocuSign immediately before re-directing the human to the signing url. Anything else will not be reliable.
If you need a longer lasting url for the signing ceremony, then use your own url, to your own application. When the user clicks on that url, your application should:
Verify the url
Obtain a signing url from DocuSign
Redirect the user to the signing url
I am working on a NodeJS application.
I am new to redis, I just installed it yesterday, but I'd like to be able publish this data and subscribe to it from another process.
Suppose I have the following data:
var Exchanges = [
{
_id: 'tsx',
name: 'Toronto Stock Exchange',
data: {
instrument: [
{
symbol: 'MBT'
markPrice: 0,
},
{
symbol: 'ACQ'
markPrice: 0,
}
],
orderBooks: [
{
symbol: 'MBT',
bids: [],
asks: [],
},
{
symbol: 'ACQ',
bids: [],
asks: [],
}
],
trades: [
{
timestamp: "2014-11-06T20:53:00.000Z",
symbol: "MBT",
side: "Buy",
size: 0,
price: 352.80,
},
{
timestamp: "2014-11-06T20:53:00.000Z"
symbol: "ACQ",
side: "Sell",
size: 0,
price: 382.90,
}
],
},
},
{
_id: 'nyse',
name: 'New York Stock Exchange',
data: {
instrument: [
{
symbol: 'IBM'
markPrice: 0,
},
{
symbol: 'WMT'
markPrice: 0,
}
],
orderBooks: [
/* Orderbook Data Here */
],
trades: [
/* Trades Data Here */
],
},
}
];
I am saving this with something like:
exchange.websocket_conn.on('message', function (updateData) {
// Use 'updateData' (a diff) to update exchange.data object.
// ...
// Then
redisClient.hmset(exchange._id.toString(), exchange.data);
redisClient.publish(exchange._id.toString(), exchange.data);
});
This works and does publish the data, however I've been reading about 'PSUBSCRIBE' and I'm wondering if this can be broken down a bit further:
I'd like to be able to do something like:
someOtherRedisClient.subscribe('tsx');
// Receive All Data from the Exchange Whenever Anything Changes.
someOtherRedisClient.subscribe('tsx.instrument');
// Receive 'Instrument' array of All Instruments on Exchange when any Instrument Changes.
someOtherRedisClient.subscribe(tsx.instrument:MBT');
// Get Back Only the 'MBT' Instrument Whenever It Changes.
Can the 'Pattern Subscribe' function be used to achieve this?
Thanks,
I'd break down that one big JSON into many JSON's, one for each type of content, e.g.
Level 1 (e.g. last trade price, best bid/ask)
Order book
Trades
and create a seperate topic for each, e.g.
mktdata:tsx:level1:MBT would have the market price for MBT on the TSX exchange
mktdata:tsx:orderbook:MBT would be the order book for MBT on the TSX exchange
mktdata:tsx:trades:MBT could be all the trades but more likely, due to volume, would be better used as a notification to the client to make a seperate query to get the last N trades required from a list
You don't say how many instruments you're writing into Redis, or how many different client applications are consuming the data, but assuming you've not got a huge number of instruments you could indeed use PSUBSCRIBE to get all orderbook updates across the exchange, etc. Given a list of symbols you can also subscribe a long list of channels (e.g. mktdata:tsx:level1:MBT mktdata:tsx:orderbook:MBT mktdata:tsx:level1:ACQ), which can run to tens/hundreds without problem.
I am using the O365 API for Calendar, which I understand is currently in preview. When querying the /Calendar/Events endpoints, all created events are returned, but does not seem to be returning the correct "Recurrence" info. I made several events in O365 that recur every workday with no end date, but the API does not seem to return this info.
Is there a workaround for this to get meeting recurring info?
Photohunts,
To see the recurrence information, you will need to navigate to the specific Event.
For example:
https://outlook.office365.com/EWS/OData/Me/Events('AAMkADU5OWRjMWIwLThmNTMtNGM0NC1iM2UwLWEzODE3NjZlOTAwYQBGAAAAAABhjWDlvPXlRIwLplz9WovhBwAGqPuO3lPFTZQQq7HNVCBIAAAB3pf9AABBCWIB9tA-TaTLczumGiYyAACHmWVwAAA=')
you will see information like this below:
Recurrence: {
Pattern: {
Type: "Weekly",
Interval: 1,
Month: 0,
Index: "First",
FirstDayOfWeek: "Sunday",
DayOfMonth: 0,
DaysOfWeek: [
"Thursday"
]
},
Range: {
Type: "EndDate",
StartDate: "2014-07-03T00:00:00-07:00",
EndDate: "2014-12-31T00:00:00-08:00",
NumberOfOccurrences: 0
}
}