-
Notifications
You must be signed in to change notification settings - Fork 100
new direct message api #229
Changes from 14 commits
b4b490b
86acb32
6abfa6b
255d4d1
fe1bd60
cb4c71d
6c385b6
c0beb29
896bdc7
6623013
bac3c5b
a5ff039
8634ff3
82a575c
349bf5f
cafb82f
7a05f8a
a677a7f
3ad4586
00e9b9f
6fb2cea
99d848a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.danielasfregola.twitter4s.entities | ||
|
||
final case class DirectMessageEvent(`type`: String, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
id: String, | ||
created_timestamp: String, | ||
message_create: MessageCreate) | ||
|
||
final case class MessageCreate(target: Target, sender_id: Option[String], message_data: MessageData) | ||
|
||
final case class Target(recipient_id: String) | ||
|
||
final case class MessageData(text: String, entities: Option[Entities] = None, attachment: Option[Attachment] = None) | ||
|
||
final case class Attachment(`type`: String, media: Media) | ||
|
||
final case class Apps(id: String, name: String, url: String) | ||
|
||
final case class SingleEvent(event: DirectMessageEvent, apps: Option[Map[String, App]]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.danielasfregola.twitter4s.entities | ||
import com.danielasfregola.twitter4s.entities.streaming.UserStreamingMessage | ||
|
||
final case class DirectMessageEventList(events: List[DirectMessageEvent], | ||
apps: Option[Map[String, Apps]], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be changed to just |
||
next_cursor: Option[String]) | ||
extends UserStreamingMessage |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.danielasfregola.twitter4s.entities | ||
|
||
private[twitter4s] final case class NewDirectMessageEvent(event: NewEvent) | ||
|
||
private[twitter4s] final case class NewEvent(`type`: String = "message_create", message_create: MessageCreate) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.danielasfregola.twitter4s.http.clients.rest.directmessages.parameters | ||
import com.danielasfregola.twitter4s.http.marshalling.Parameters | ||
|
||
private[twitter4s] final case class EventListParameters(count: Int, next_cursor: Option[String]) extends Parameters |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package com.danielasfregola.twitter4s.http | ||
package oauth | ||
|
||
import akka.http.scaladsl.model._ | ||
import akka.http.scaladsl.model.headers.RawHeader | ||
import akka.http.scaladsl.model.{HttpHeader, HttpRequest} | ||
import akka.stream.Materializer | ||
import com.danielasfregola.twitter4s.entities.{AccessToken, ConsumerToken} | ||
import com.danielasfregola.twitter4s.util.{Encoder, UriHelpers} | ||
|
@@ -80,7 +80,9 @@ private[twitter4s] class OAuth1Provider(consumerToken: ConsumerToken, accessToke | |
implicit val ec = materializer.executionContext | ||
extractRequestBody.map { body => | ||
val cleanBody = body.replace("+", "%20") | ||
if (cleanBody.nonEmpty) { | ||
if (cleanBody.nonEmpty && request.entity | ||
.getContentType() | ||
.mediaType == MediaTypes.`application/x-www-form-urlencoded`) { | ||
mitgard marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to check this before merging, as this could break other endpoints' authentication. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be we return |
||
val entities = cleanBody.split("&") | ||
val bodyTokens = entities.flatMap(_.split("=", 2)).toList | ||
bodyTokens.grouped(2).map { case List(k, v) => k -> v }.toMap | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"event": { | ||
"type": "message_create", | ||
"id": "1044927409530647812", | ||
"created_timestamp": "1537965082782", | ||
"message_create": { | ||
"target": { | ||
"recipient_id": "773439338287913984" | ||
}, | ||
"sender_id": "24130273702", | ||
"message_data": { | ||
"text": "New test message", | ||
"entities": { | ||
"hashtags": [], | ||
"symbols": [], | ||
"user_mentions": [], | ||
"urls": [] | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"events" : [ { | ||
"type" : "message_create", | ||
"id" : "1044927409530647812", | ||
"created_timestamp" : "1537935082782", | ||
"message_create" : { | ||
"target" : { | ||
"recipient_id" : "773439338287913984" | ||
}, | ||
"sender_id" : "24130273702", | ||
"message_data" : { | ||
"text" : "New test message", | ||
"entities" : { | ||
"hashtags" : [ ], | ||
"symbols" : [ ], | ||
"user_mentions" : [ ], | ||
"urls" : [ ] | ||
} | ||
} | ||
} | ||
} ], | ||
"apps" : { | ||
"14855158" : { | ||
"id" : "14855158", | ||
"name" : "TestApplication", | ||
"url" : "http://TestApplicationUrl.ru/" | ||
} | ||
}, | ||
"next_cursor" : "MTA0NDkyNzQwOTAzMDY0NzgxMg" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"event": { | ||
"type": "message_create", | ||
"id": "1044927409530647812", | ||
"created_timestamp": "1537965082782", | ||
"message_create": { | ||
"target": { | ||
"recipient_id": "773439338287913984" | ||
}, | ||
"sender_id": "24130273702", | ||
"message_data": { | ||
"text": "New test message", | ||
"entities": { | ||
"hashtags": [], | ||
"symbols": [], | ||
"user_mentions": [], | ||
"urls": [] | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"events" : [ { | ||
"type" : "message_create", | ||
"id" : "1044927409530647812", | ||
"created_timestamp" : "1537935082782", | ||
"message_create" : { | ||
"target" : { | ||
"recipient_id" : "773439338287913984" | ||
}, | ||
"sender_id" : "24130273702", | ||
"message_data" : { | ||
"text" : "New test message", | ||
"entities" : { | ||
"hashtags" : [ ], | ||
"symbols" : [ ], | ||
"user_mentions" : [ ], | ||
"urls" : [ ] | ||
} | ||
} | ||
} | ||
} ], | ||
"apps" : { | ||
"14855158" : { | ||
"id" : "14855158", | ||
"name" : "TestApplication", | ||
"url" : "http://TestApplicationUrl.ru/" | ||
} | ||
}, | ||
"next_cursor" : "MTA0NDkyNzQwOTAzMDY0NzgxMg" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
fatal-warnings
flag is too important to remove it.If you cannot find a way to let the tests involving deprecation pass, I would rather delete them that removing the flag.