-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
191 additions
and
78 deletions.
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
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,51 @@ | ||
export async function pollCreation(idUser, poll) { | ||
if (typeof poll !== 'object') { | ||
return WAPI.scope(idUser, true, 404, 'poll must be an object'); | ||
} | ||
if (!poll?.name) { | ||
return WAPI.scope(idUser, true, 404, 'Missing object name'); | ||
} | ||
if (!poll?.options) { | ||
return WAPI.scope(idUser, true, 404, 'Missing object options'); | ||
} | ||
if ( | ||
typeof poll.selectableOptionsCount !== 'number' || | ||
(poll.selectableOptionsCount !== 1 && poll.selectableOptionsCount !== 0) | ||
) { | ||
return WAPI.scope( | ||
idUser, | ||
true, | ||
404, | ||
'Error checking selectableOptionsCount!' | ||
); | ||
} | ||
|
||
const options = poll.options; | ||
if (Array.isArray(options) && options.length > 0) { | ||
for (let index in options) { | ||
if (typeof options[index] !== 'function') { | ||
if (!options[index].name) { | ||
return WAPI.scope(idUser, true, 404, 'Missing object name'); | ||
} | ||
if (typeof options[index].name !== 'string') { | ||
return WAPI.scope(idUser, true, 404, 'Passed string value in name'); | ||
} | ||
} | ||
} | ||
} | ||
|
||
const chat = await WAPI.sendExist(idUser); | ||
if (chat && chat.status !== 404 && chat.id) { | ||
await Store.Survey.sendPollCreation({ | ||
chat: chat, | ||
poll: poll, | ||
quotedMsg: null | ||
}); | ||
return { error: false, lastReceivedKey: chat.lastReceivedKey }; | ||
} else { | ||
if (!chat.error) { | ||
chat.error = true; | ||
} | ||
return chat; | ||
} | ||
} |
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,8 @@ | ||
export function addOnPoll() { | ||
window.WAPI.onPoll = function (callback) { | ||
Store.PollVote.on('change', (e) => { | ||
callback(e); | ||
}); | ||
return true; | ||
}; | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.