This repository has been archived by the owner on Jul 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 593
Attachment forwarding #435
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
91b85e3
Implementing forwardAttachment
gamelaster d97fb7e
Changing argument names
gamelaster b8fd35c
Adding documentation for forwardAttachment
gamelaster 8c99527
Removing dpr and rephrasing documentation
gamelaster e2630e4
Fixing tipo in attachmentID
gamelaster eefd32a
Rephrasing description of forwardAttachment
gamelaster File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use strict"; | ||
|
||
var utils = require("../utils"); | ||
var log = require("npmlog"); | ||
|
||
module.exports = function(defaultFuncs, api, ctx) { | ||
return function forwardAttachment(attachmentID, userOrUsers, callback) { | ||
if (!callback) { | ||
callback = function() {}; | ||
} | ||
|
||
var form = { | ||
attachment_id: attachmentID, | ||
}; | ||
|
||
if(utils.getType(userOrUsers) !== "Array") { | ||
userOrUsers = [userOrUsers]; | ||
} | ||
|
||
var timestamp = Math.floor(Date.now() / 1000); | ||
|
||
for (var i = 0; i < userOrUsers.length; i++) { | ||
//That's good, the key of the array is really timestmap in seconds + index | ||
//Probably time when the attachment will be sent? | ||
form['recipient_map[' + (timestamp + i) + ']'] = userOrUsers[i]; | ||
} | ||
|
||
defaultFuncs | ||
.post("https://www.messenger.com/mercury/attachments/forward/", ctx.jar, form) | ||
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs)) | ||
.then(function(resData) { | ||
if (resData.error) { | ||
throw resData; | ||
} | ||
|
||
return callback(null); | ||
}) | ||
.catch(function(err) { | ||
log.error("forwardAttachment", err); | ||
return callback(err); | ||
}); | ||
}; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I would rephrase it this way:
"Forwards corresponding attachment to given userID or to every user from an array of userIDs"
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.
Done