Dear appwrite community,
I implemented a simple sms verification for my flutter app. When I want to send a verification sms via text-magic, the appwrite messaging worker log the following error.
[notice] Starting work on (Job{v1-messaging} | ID: e8dbb2e55c8e618a1e31179d42f9a22f | MessagingV1 | [{"project":null,"user":null,"payload":[],"recipient":"+123456789","message":"123456","events":["."]}])
[critical] (Job{v1-messaging} | ID: e8dbb2e55c8e618a1e31179d42f9a22f | MessagingV1 | [{"project":null,"user":null,"payload":[],"recipient":"+123456789","message":"123456","events":["."]}]) has failed TypeError: strlen(): Argument #1 ($str) must be of type string, array given in /usr/src/code/vendor/utopia-php/messaging/src/Utopia/Messaging/Adapter.php:59
Stack trace:
#0 /usr/src/code/vendor/utopia-php/messaging/src/Utopia/Messaging/Adapters/SMS/TextMagic.php(54): Utopia\Messaging\Adapter->request('POST', 'https://rest.te...', Array, Array)
#1 /usr/src/code/vendor/utopia-php/messaging/src/Utopia/Messaging/Adapters/SMS.php(33): Utopia\Messaging\Adapters\SMS\TextMagic->process(Object(Utopia\Messaging\Messages\SMS))
#2 /usr/src/code/app/workers/messaging.php(69): Utopia\Messaging\Adapters\SMS->send(Object(Utopia\Messaging\Messages\SMS))
#3 /usr/src/code/src/Appwrite/Resque/Worker.php(121): MessagingV1->run()
#4 /usr/src/code/vendor/resque/php-resque/lib/Resque/Job.php(201): Appwrite\Resque\Worker->perform()
#5 /usr/src/code/vendor/resque/php-resque/lib/Resque/Worker.php(303): Resque_Job->perform()
#6 /usr/src/code/vendor/resque/php-resque/lib/Resque/Worker.php(242): Resque_Worker->perform(Object(Resque_Job))
#7 /usr/src/code/vendor/resque/php-resque/bin/resque(185): Resque_Worker->work('1', false)
#8 {main}
There is no sms send, but the user is created in my appwrite console.
I've setup the phoneSession like this.
startPhoneSession(String phone) async {
try {
_user ??= User();
if (account == null) {
_init();
}
var token =
await account!.createPhoneSession(userId: ID.unique(), phone: phone);
_user!.id = token.userId;
_storeUserId();
} catch (error) {
//Do something with the error...
print(error);
}
}
My .env variables are set like the docs say with the username and apikey from text-magic.
It feels like a issue with appwrite right? If you need anymore information feel free to ask :)
Cheers!
This does look like it might be a bug. The best place to report bugs would be Appwrite's GitHub repo. I would suggest creating an issue there.
Related
I think that this's an issue many coders are facing at the moment.
So let's find a solution:
I already tried ->
mailer2: ^1.2.5
var options = GmailSmtpOptions()
..username = ''
..password = '';
var emailTransport = SmtpTransport(options);
var envelope = Envelope()
..from = ''
..recipients.add(email)
..subject = ''
..html = "<h1>Title </h1>\n\n"
emailTransport.send(envelope)
.then((envelope) => print('Email sent!'))
.catchError((e) => print('Error occurred: $e'));
but the following error message came up:
Unsupported operation: Platform._localHostname
at Object.throw_ [as throw] (http://localhost:63913/dart_sdk.js:4463:11)
at Function._localHostname (http://localhost:63913/dart_sdk.js:54754:17)
at Function.get localHostname [as localHostname] (http://localhost:63913/dart_sdk.js:54810:33)
at get _localHostname (http://localhost:63913/dart_sdk.js:54713:27)
at Function.desc.get [as _localHostname] (http://localhost:63913/dart_sdk.js:4944:15)
at Function.get localHostname [as localHostname] (http://localhost:63913/dart_sdk.js:54666:26)
at mailer.GmailSmtpOptions.new.mailer.SmtpOptions.new
(http://localhost:63913/packages/mailer2/mailer.dart.lib.js:1178:30)
at new mailer.GmailSmtpOptions.new (http://localhost:63913/packages/mailer2/mailer.dart.lib.js:1229:43)
at http://localhost:63913/packages/bestbite_native/web/screens/screen_after_order.dart.lib.js:12394:37
at Generator.next (<anonymous>)
at runBody (http://localhost:63913/dart_sdk.js:37195:34)
at Object._async [as async] (http://localhost:63913/dart_sdk.js:37226:7)
at http://localhost:63913/packages/bestbite_native/web/screens/screen_after_order.dart.lib.js:12392:389
at _RootZone.runUnary (http://localhost:63913/dart_sdk.js:37029:58)
at _FutureListener.then.handleValue (http://localhost:63913/dart_sdk.js:32116:29)
at handleValueCallback (http://localhost:63913/dart_sdk.js:32663:49)
at Function._propagateToListeners (http://localhost:63913/dart_sdk.js:32701:17)
at _Future.new.[_completeWithValue] (http://localhost:63913/dart_sdk.js:32544:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:63913/dart_sdk.js:32566:35)
at Object._microtaskLoop (http://localhost:63913/dart_sdk.js:37290:13)
at _startMicrotaskLoop (http://localhost:63913/dart_sdk.js:37296:13)
at http://localhost:63913/dart_sdk.js:32918:9Error: Unsupported operation: Platform._localHostname
Does anybody has an idea how to send emails in flutter web applications?
(Without opening an email tab)
"mailer2"(and the original package "mailer") imports dart:io which is not available on flutter web and therefore you cannot use this package.
A solution I have used in the past for sending emails is to create an http-triggered cloud function(e.g. Firebase functions, AWS Lambda, netlify functions) that sends the email. You can pass any data you need through the http request and have the cloud function send the email through something like nodemailer in Node.js.
There also may be other services or APIs available that already do what the cloud function does, though I have not seen many and they are not my preferred method
I initialize the chat client using chat token .
i have two members in each channel . I want to know whether the user online or not.
For that in backend i added twilio chat service instance { reachabilityEnabled: true } as the doc says
and in frontend i wrote this code to get memebers information.
var member = await this.myChannel.getMembers();
member.forEach((member)=>{
console.log(member)
member.on('userInfoUpdated', (m)=>{
console.log(m);
})
member.on('updated', (m)=>{ console.log("hey")
console.log(m);
})
})
but in member object i'm not getting any element from that i can check whether is user online or not.
this is response of member object
channel: t {…}
services: e {…}
state: {attributes: {…}, dateCreated: Fri May 15 2020 19:---- (India Standard Time), dateUpdated: Fri May 1------------ (India Standard Time), sid: "MB7545cfa292314570a39385943ac541ad", typingTimeout: null, …}
_events: {updated: Array(2), userInfoUpdated: ƒ}
_eventsCount: 2
_maxListeners: undefined
attributes: (...)
dateCreated: (...)
dateUpdated: (...)
identity: (...)
isTyping: (...)
lastConsumedMessageIndex: (...)
lastConsumptionTimestamp: (...)
roleSid: (...)
sid: (...)
type: (...)
Please suggest me some way how will i do it because i'm stuck here very badly .
if you need more code or information about this flow let me know but please suggest me some way. because there are question for this concern on any platform so from where i can clear it .
Member and User are similar yet different objects. I believe your looking for the User resource to determine the IsOnline status.
After fetching your members; you can then use the members Identity to perform a user fetch which will give you that users IsOnline status.
See: Twilio User support docs.
I can't find information about acceptable response content or code status from my site to zapier app on test step.
I have my site on Laravel and Zapier app for this site. In my Zapier app I have an action: "Create New Project". I made my "create" according to the example. Everything works except the testing step. I tested with the following zap:
Trello -> "New card created" trigger. Test successful.
My app -> "Create new project". Test fails with We had trouble sending your test through. Could not handle special, non-standard characters. Please contact support.
Strangely, the project was created successfully. Therefore, I think the problem lies in the response from my site to zapier:
// creates/project.js
// My perform function:
perform: (z, bundle) => {
const promise = z.request({
url: `${process.env.BASE_URL}/api/folder`,
method: 'POST',
body: JSON.stringify({
title: bundle.inputData.title,
}),
headers: {
'content-type': 'application/json',
}
});
return promise.then((response) => JSON.parse(response.content));
}
//ZapierController.php
public function addFolder(Request $request)
{
// Made record to DB, and other, after this returned same data which in request
return response()->json(['title' => $request['title']]);
}
Expected result - successful test on "Test this step". Can anyone help me?
David here, from the Zapier Platform team.
I already answered your support ticket, but I figured I'd reply here in case anyone else has the same issue.
The root problem is made clear when you run zapier logs on the cli:
== Log
Unhandled error: CheckError: Invalid API Response:
- Got a non-object result, expected an object from create ("title")
What happened:
Executing creates.сFolder.operation.perform with bundle
Invalid API Response:
- Got a non-object result, expected an object from create ("title")
Your server can reply with any 2xx status code, but the output needs to be valid json. Something like {"title": "my title here"} would certainly work. Users find it more helpful to get info about the project they just created, so the name, id, etc would be even better.
As for why this surfaced as a character encoding issue, I have no clue. We plan on getting to the bottom of it though!
I am running parse-server on Heroku, I am working on implementing a custom cloud code function, however every implementation returns invalid function code: 141, Version:1.12.0
I have successfully gotten the "hello" function to work, including 1 change I made to it:
Parse.Cloud.define('hello', function(req, res) {
console.log("received.........");
res.success('Hi');
});
The custom function I am trying to get working is a simple query to my database:
Parse.Cloud.define("titleQuery", function(request, response) {
var query = new Parse.Query("StudentNotes");
query.equalTo("title", request.params.title);
query.find({
success: function(results) {
console.log("received........." + results);
response.success(results);
},
error: function() {
console.log("received........." + error);
response.error("title lookup failed");
}
});
});
When I run this on iOS with the following code:
PFCloud.callFunctionInBackground("titleQuery", withParameters: ["title": "testTitle"]) {
(response: AnyObject ? , error : NSError ? ) - > Void in
let hello = response // as? String
print(hello)
}
I am querying my database in class "StudentNotes" for object title with the name "testTitle", I know for a fact that that object exists, however due to it throwing error 141 I do not receive anything. Any help would be greatly appreciated.
EDIT2: I have gotten custom cloud functions to work, however I cannot get any queries to my database to work. Can anyone post a confirmed working query that returns an object? Perhaps from the _User table so that I can copy/paste and ensure that my cloud code can access my database?
My process:
I edit the Main.js file and add in my cloud function.
Then i commit & push (successfully)
finally i restart my Heroku server
Then i still get an error 141 invalid function return
I have successfully solved this problem and gotten regular queries to work. The problem was in my Heroku config vars in the dashboard. My server URL was invalid, never changed from the default of "http://yourappname.com/parse/" I have to manually enter "yourappname".
I've been debugging this issue for days, but I can't think of anything else to try to fix this.
The error:
Fatal error: Uncaught exception 'Google_AuthException' with message 'Error refreshing the OAuth2 token, message: '{
"error" : "invalid_grant"
}'' in /html/cms/php/google-api-php-client/src/auth/Google_OAuth2.php:279
Stack trace:
#0 /html/cms/php/google-api-php-client/src/auth/Google_OAuth2.php(256): Google_OAuth2->refreshTokenRequest(Array)
#1 /html/cms/php/google-api-php-client/src/auth/Google_OAuth2.php(209): Google_OAuth2->refreshTokenWithAssertion()
#2 /html/cms/php/google-api-php-client/src/service/Google_ServiceResource.php(166): Google_OAuth2->sign(Object(Google_HttpRequest))
#3 /html/cms/php/google-api-php-client/src/contrib/Google_CalendarService.php(154): Google_ServiceResource->__call('list', Array)
#4 /html/cms/php/google_calendar_sync.php(41): Google_CalendarListServiceResource->listCalendarList()
#5 {main}
thrown in /html/cms/php/google-api-php-client/src/auth/Google_OAuth2.php on line 279
My server's clock is in sync:
2 Jan 13:35:36 ntpdate[1214]: adjust time server 62.212.76.57 offset 0.003544 sec
(62.212.76.57 being my colo company's time server)
I've triple checked my service account developer credentials at the Google APIs Console (I had a screenshot, but I can't use it because my account is too new :/). I've also successfully subscribed to the calendar service (also can't use the screenshot I made of this).
My code:
<?php
require_once(dirname(__FILE__) . '/google-api-php-client/src/Google_Client.php');
require_once(dirname(__FILE__) . '/google-api-php-client/src/contrib/Google_CalendarService.php');
session_start();
define('CLIENT_ID', 'XXXXXX510496.apps.googleusercontent.com');
define('SERVICE_ACCOUNT_NAME', 'XXXXXX510496#developer.gserviceaccount.com');
define('CALENDAR_ID', 'XXXXXXXXXXXXXXXXX');
define('KEY_FILE', dirname(__FILE__) . '/private/XXXXXXXXXXXXXXXXXXXX881a845ed4e4d2d58eb1-privatekey.p12');
$client = new Google_Client();
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
$key = file_get_contents(KEY_FILE);
$client->setClientId(CLIENT_ID);
$client->setAssertionCredentials(new Google_AssertionCredentials(
SERVICE_ACCOUNT_NAME,
'https://www.google.com/calendar/feeds/' . CALENDAR_ID . '/private/full/',
$key)
);
$service = new Google_CalendarService($client);
$calendarList = $service->calendarList->listCalendarList();
echo "<h1>Calendar List</h1><pre>" . print_r($calendarList, true) . "</pre>";
?>
I've completely run out of ideas, so any help would be hugely appreciated!
I just posted a document that might help you get unstuck:
http://www.tqis.com/eloquency/googlecalendar.htm