Coder Social home page Coder Social logo

fosmessagebundle's People

Contributors

alexkovalevych avatar dfridrich avatar emgiezet avatar emmanuelvella avatar encreinformatique avatar fogs avatar gimler avatar guilhemn avatar helios-ag avatar hex333ham avatar jacobmaster avatar jmikola avatar kaiwa avatar khepin avatar merk avatar miliooo avatar nelrann avatar nyholm avatar ornicar avatar pentarim avatar riki4321 avatar sallaigy avatar sheeep avatar stephane-monnot avatar stof avatar tgalopin avatar vslinko avatar youbs avatar zaloster avatar zocimek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fosmessagebundle's Issues

Inbox and sent message in one page

Hi and thanks for this awesome bundle ! :)

I want to show messaging in conversation instead of sent/inbox system, like sms in your smartphone.

Is it possible to do that ? What is the best way ?

Thanks for your help,

Sullivan.

Tagging threads

I'm needing a way of adding tags to threads in much the same way as gmail. Ideally a thread could have several tags rather than being placed into one "folder". I was wondering if this was something that anyone else had already implemented or was a feature being developed by the core team.

Send message by user id instead of username

Hi,
I need to choose my participants by user id instead of username.
What is the best way to do it?

I'm using FOSUserBundle, FOSFacebookBundle and FOSMessageBundle.

Many Thanks!

Luca

Do not enforce naming convention for metadata classes

The mongodb.xml and orm.xml DI configuration files define:

    <parameters>
        <parameter key="ornicar_message.message_meta_class">%ornicar_message.message_class%Metadata</parameter>
        <parameter key="ornicar_message.thread_meta_class">%ornicar_message.thread_class%Metadata</parameter>
    </parameters>

This should be changed so as not to enforce a naming convention for metadata classes.

No translations for form errors in French

I can't find translations for errors in form with the recipient field in the bundle.

And it's the same case for all the errors for the forms of the bundle !
And when I go to the page of search, I've this error : not yet implemented !

How to add a custom field to the Thread Entity?

Hi!

I am trying to add a new field to the Thread entity and to display it in the newThreadMessage form.

I currently added my field to the entity with its getter and setter, I created a custom NewThreadMessageFormType which extends Ornicar\MessageBundle\FormType\NewThreadMessageFormType but now I am stuck at this point as I get an error saying:

Neither property "foo" nor method "getFoo()" nor method "isFoo()" exists in class 
"Ornicar\MessageBundle\FormModel\NewThreadMessage"

I guess I should overload also the NewThreadModel class, but in this way I am forced to override the FormHandler and FormFactory as well.

Is this the right way to go?

Thanks,
Andrea

setting message as read broken

Error message is:

An exception occurred while executing 'UPDATE MessageMetadata SET is_read = 1 WHERE id = ?' with params {"1":1}:

SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "is_read" is of type boolean but expression is of type integer
LINE 1: UPDATE MessageMetadata SET is_read = 1 WHERE id = $1
^
HINT: You will need to rewrite or cast the expression.

I could trace this to EntityManager/MessageManager.php, line 135-143. Verified by commenting that out, after which the error disappears (but, of course, messages aren't marked as read anymore).

There appears to be an obvious cast error in line 137, but replacing (int) with (boolean) does not solve it, unfortunately. This is as far as I'm able to find the root cause.

Sending MP with the service

When I send a MP with the services :

$composer = $this->get('fos_message.composer');
$sender = $this->get('fos_message.sender');

Users cannot recieve its because the last_participant_message_date in message_thread_metadata is empty.

Here is my code for information:

$composer = $this->get('fos_message.composer');
        $sender = $this->get('fos_message.sender');

        foreach($reportage->getAuteurs() as $auteur)
        {
            $message = $composer->newThread()
                ->setSender($this->container->get('security.context')->getToken()->getUser())
                ->addRecipient($auteur)
                ->setSubject('blah')
                ->setBody("blah blah.")
                ->getMessage();

            $sender->send($message->getMessage());
        }

Thanks a lot to fix this bug,

remontees

Using simple references in MongoDB

In mongodb documentation it's written that manual references should be used instead of DBRefs where possible. In FOSMessageBundle DBRefs are used for referensing participants, messages and threads. But we know what we are referencing. So the right way is to use manual references.

If this bundle will support both manual and DBRefs, new users will be able to use manual references. I'd like to know if this is acceptable. If yes, I'll provide the patch.

messageManager mark as read/unread

in the MessageManager the markAsReadByParticipant ask for a ReadableInterface as first argument but it use another method markIsReadByThreadAndParticipant who accept only a ThreadInterface as first arg.

<?php
    public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
    {
        $this->markIsReadByThreadAndParticipant($readable, $participant, true);
    }

    /**
     * Marks the readable as unread by this participant
     *
     * @param ReadableInterface $readable
     * @param ParticipantInterface $participant
     */
    public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
    {
        $this->markIsReadByThreadAndParticipant($readable, $participant, false);
    }

    /**
     * Marks all messages of this thread as read by this participant
     *
     * @param ThreadInterface $thread
     * @param ParticipantInterface $participant
     * @param boolean $isRead
     */
    public function markIsReadByThreadAndParticipant(ThreadInterface $thread, ParticipantInterface $participant, $isRead)
    {
        foreach ($thread->getMessages() as $message) {
            $this->markIsReadByParticipant($message, $participant, $isRead);
        }
    }

Is there any plan to make it more coherant?
thanks

Inconsistent behavior in Message::setIsReadByParticipant()

Comparing the document method with the entity method, the entity is prone to throwing an exception if the participant does not exist. The document is more robust in that it will simply set the value in its hash.

I noticed that Thread::setIsDeletedByParticipant() for both the document and entity models did not have this behavior of throwing an exception for an unrecognized participant.

I'm currently working on refactoring the documents (for MongoDB scalability issues), and I was curious what the proper behavior should be. Ideally, all of these methods (for both setting isReadBy and isDeleted) should be consistent with one another.

Issue with MessageManager

In commit f42b283, changing the method arguments resulted in an interface mismatch.

Declaration of FOS\MessageBundle\EntityManager\MessageManager::markAsReadByParticipant() must be compatible with that of FOS\MessageBundle\ModelManager\ReadableManagerInterface::markAsReadByParticipant()

Confusion in documentation about MongoDB

Hi,

Under "Creating concrete model classes" -> "MongoDB", it says:

"The MongoDB implementation does not provide concrete models. You must create Thread and Message classes in your application."

But then go on and reference the Metadata classes.

The ORM-part, has the metadata concrete classes.

setLastParticipantMessageDate() must be an instance of DateTime

Hello.

I have the bundle equal the documentation.
Only I created the entity Message, Thread, MessageMetadata and ThreadMetadata.

I get the following error:

Catchable Fatal Error: Argument 1 passed to FOS\MessageBundle\Model\ThreadMetadata::setLastParticipantMessageDate() must be an instance of DateTime, null given, called in /var/www/workspace/chateagratis/vendor/friendsofsymfony/message-bundle/FOS/MessageBundle/EntityManager/ThreadManager.php on line 332 and defined in /var/www/workspace/chateagratis/vendor/friendsofsymfony/message-bundle/FOS/MessageBundle/Model/ThreadMetadata.php line 73 

I don't find the solution... I will try reinstall the bundle.

Any idea why this error ocurrs?

Bad choice of method name in ParticipantInterface

Hi,

I am about to implement this bundle in our application, but we need to have messages between different kinds of participants i.e. an user and a department (not a specific user within the apartment).

We are using Doctrine2 ORM entities with a MySQL backend but I think the issue applies a lot broader than to this setup.

I expected that I could just implement the participant interface for both entities but the the naming of the sole method within that interface is really limiting. the getId() method is commonly used (at least for many of the projects I have seen or been involved in) to reference to the primary key of the database, these are seldom unique across different model entities. This means that I cannot just implement the participant interface on my to types of entities and use this bundle as the id will be ambiguous.

I will gladly make a PR and change the interface method name and all references to it to something along the lines of getParticipantId() which is less likely to clash with existing methods on the models used. This would introduce a BC break though, so before I do this I would like to hear your thoughts about this issue and see if you have other ideas on how to support such a use case without introducing a BC break.

/ Jesper

threadMetadata.lastMessageDate should be null while not

If you just create a new thread, you'll see this one in your inbox. This is not intentional.

After a little dig into source code, EntityManager/ThreadManager::findParticipantInboxThreads does select threads that have at least one message written by another participant by 'tm.lastMessageDate IS NOT NULL', while lastMessageDate is NOT NULL even was just created. It's 1970-01-01 08:00:00.

This is caused by, in doDatesOfLastMessageWrittenByOtherParticipant, timestamp is default set to 0, which will be set to lastMessageAt. So you can fix this issue by wrap
$date = new \DateTime();
$date->setTimestamp($timestamp);
$meta->setLastMessageDate($date);
in $timestamp > 0 condition.

NewThreadMessageFormType depends on FOSUserBundle

According to the docs, FOSUserBundle is an optional dependency; however, the recipient field in NewThreadMessageFormType depends on the fos_user_username field type.

I found some reference to a FOSUserBundle dependency in #16, but no discussion about it being optional.

@ornicar: Can you chime in on this? Should NewThreadMessageFormType, as provided by the bundle, support a configurable field type for recipient? That seems preferable to having two separate types, one using the FOS field and another a standard text input.

Tests...!!!

Hey, @zocimek I have a problem with the fact that we don't really have tests on this bundle.
Makes it hard to makes some PRs because I'm unsure if there will be some BC breaks or anything.

I don't know how much time you can keep for this now. I'm gonna start adding some tests when I can though. Hope we can both work on that a bit.

How can I personalize the forms ?

I installed the FOSMessageBundle but I want add some custom fields.

I seen in the documentation that config.yml can specify the form can use.

But I added the config and I get the following error:

InvalidArgumentException: An alias can not reference itself, got a circular reference on "fos_message.message_manager".

How can I personalize the forms, without modify the FOSMessageBundle?

Thanks!

performance - saveMessage crazy slow

I'm hunting performance issues in my code and I've found that this call:

    $this->messageManager->saveMessage($message);

in Sender.php, method send is sometimes taking several SECONDS. I'm measuring the time between the line right before and the one right after:

$sub_start = microtime(true);
$this->messageManager->saveMessage($message);
$t = (microtime(true)-$sub_start); if ($t>0.02) echo(" - saveMessage 2: $t s\n");

Something very strange is going on. In 7 seconds I should be able to save a hundred messages, not one.

Styling messages

I'm wanting to be able to apply css styles to a message when I display it to an end user. However, if I store a message with html tags then the tags are not parsed by the twig engine when I render the template. Is there a way around this? Also, is it good practice and safe to store html in the db?

Bundle missing on packagist

The bundle has a composer.json file but is not registered on packagist, making it harder to use it through composer.

So please register it on packagist
`
Thx you

Multiple inboxes

Hey, wondering what's the thoughts on this, but I'd like to see this bundle be able to manage multiple inboxes for each user. A first use case I can point out is for example the way notifications are done on Github. A notification could be a special kind of message that would appear in a different inbox.

I can see a few different ways to do this and currently trying to implement one that doesn't require changing the bundle's code.

If there is some interest, I could try and see how to actually make it work inside of the bundle.

Licence

Looks pretty nice :) (I bet even more after you refactored and documented it ;)

Do you think of offering it to the community? ;) If so, what licence are you going to use?
Cheers!

Hide username form field

Hi,
my messagebundle is ok but I want to hide the username form field.
What is the best way to do it?

Many thanks!

Cannot override validation

I wanna override default error messages by creating a validation.xml in my message bundle's Resources/config directory. The bundle's parent is OrnicarMessageBundle.

But I found that validations are done twice, with both error messages from my validation.xml and Ornicar's. Though I can achieve this by creating validators.xx.yml, I'm confused that why overriding does not work, as it's clearly stated on symfony.com.

Thanks.

Use admin to send messages

This bundle is great! congrats!

I am using an admin to notify the users automatically when they do something on the website. This works really well but I was wondering if there is a way at the moment to block their answers? I mean I don't want them to reply to the messages sent by this particular user (admin in this case) :-)
As far as I know, this is not implemented yet, is it?

Many thanks

remove old branch

i think the branch usernameFormType was allready merged so please remove it to avoid confusion

Missing views

All views for your bundle are missing.

According to MessageController, there should be:

  • Message/inbox.html.twig
  • Message/sent.html.twig
  • Message/thread.html.twig
  • Message/search.html.twig

Thanks for your work. I start to add orm support :)

ORM automapping

i am not sure if i get this right, but you talk about setting automapping in MongoDB

doctrine_mongo_db:
document_managers:
default:
mappings:
OrnicarMessageBundle: ~
# your other bundles

how about ORM? how do i set things up if i have

doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: LATIN1
mapping_types:
enum: string
binary: string
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true

Marking as read removes the metadata => errors

Right now, when a message is marked as read, the condition evaluated in MessageManager::markIsReadByCondition erases the metadata instead of just setting the boolean isRead: true.

This query:

$queryBuilder
            ->field('metadata.$.isRead')->set((boolean) $isRead)
            ->getQuery(array('multiple' => true))
            ->execute();

produces:

db.Message.update({ 
    "thread.$id": ObjectId("502cfe967fa988d46a000000"), 
    "metadata.participant.$id": ObjectId("502cfe617fa988216c000004") 
}, { 
    "$pull": { "unreadForParticipants": "502cfe617fa988216c000004" }, 
    "$set": { "metadata.$": true } 
});

Instead of

db.Message.update({ 
    "thread.$id": ObjectId("502cfe967fa988d46a000000"), 
    "metadata.participant.$id": ObjectId("502cfe617fa988216c000004") 
}, { 
    "$pull": { "unreadForParticipants": "502cfe617fa988216c000004" }, 
    "$set": { "metadata.$.isRead": true } 
});

I don't know exactly where this is coming from, but this makes it impossible to do anything with these messages afterwards as errors are thrown because the metadata cannot be found anymore.

FOSMessageBundle.es.yml

This is the translate to spanish.

messenger: Mensajes
inbox: Carpeta de entrada
sent: Enviado
send_new: Enviar nuevo mensaje
search: Buscar
threads_found: %num% hilo encontrado | %num% hilos encontrados

message_info: Por %sender%, el %date%
reply: Responder

subject: Asunto
starter: Emisor
startdate: Fecha de emisión
messages: Mensajes
last_message: Último mensaje
actions: Acciones
new: Nuevo
goto_last: Ir al último mensaje
on: En %date%
by: Por %sender%
no_thread: No hay hilos que mostrar

Error : Could not load type "fos_user_username"

Hi @ornicar ,

Could not load type "fos_user_username" is the error message when I try to compose a new message.

PS: i have the latest version of your bundle / Symfony and UserBundle.

Am I doing something wrong or is it a bug ?

Must be logged in with a ParticipantInterface instance

Hello,

I'm connected with success, but when I go to the FOSMessage's root, I've this error : Must be logged in with a ParticipantInterface instance

What can I do ? I've not seen anything about in the documentation.

remontees

thread->addParticipant() not working

should thread->addParticipant() work? Because it appears to me it is not and can not be functional. The methods in Document/Thread.php and Entity/Thread.php only add to the internal ArrayCollection used in Thread.php - which is not mapped to the database. They should add to the Metadata, but they don't seem to be doing that.

Am I missing something or is this broken?

Version numbering

@zocimek , wanted to check why you tagged the version as 2.1. I'm not in favor of having bundle versions follow the same version numbers as symfony. I'd rather we tag a version 1.0 after merging many to many messages and remove the 2.1.

If there was no specific reason to tag 2.1, I'll remove it and add versions that match the development of this specific bundle.

Translation affects validation

By increasing the body MinLength limit to something higher than 1

<!-- in Ornicar/MessageBundle/Resources/config/validation.xml -->
        <property name="body">
            <constraint name="NotBlank">
                <option name="message">Please enter a body</option>
            </constraint>
            <constraint name="MinLength">
                <option name="limit">4</option>
                <option name="message">The body is too short</option>
            </constraint>
        </property>

and typing a body shorter than 4 letters, the validation does not take place properly:

An exception has been thrown during the rendering of a template ("Unable to choose a translation for "The body is too short" with locale "en". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %count% apples").") in OrnicarMessageBundle:Message:newThread.html.twig at line 8.

Mark message as read is broken for ODM

I create thread from one person to another and when another person "reads" it, metadata for image brokes by query like:

db.Message.update({ "thread.$id": ObjectId("501c2a7b3a37eaf203000000"), "metadata.participant.$id": ObjectId("501c1b293a37eaf303000000") }, { "$pull": { "unreadForParticipants": "501c1b293a37eaf303000000" }, "$set": { "metadata.$": true } });

Then in page of thread I got

Fatal error: Call to a member function getId() on a non-object in vendor/ornicar/message-bundle/Ornicar/MessageBundle/Model/Message.php on line 160

Anyone can see same thing?

Twig fos_message_nb_unread returns unread messages by sender as well as recipient

If I am a message author and I send a message to user, the count returned by fos_message_nb_unread will increment as long as that user has not read that message.

This may be by intention, in which case feel free to close this, however, I would expect to use this function as a way to read unread messages in a user's inbox directed towards the authenticated user. The use case to get the number of unread messages for messages as an author and recipient don't seem as wide.

Steps to reproduce:

  1. Send a user a new message via MessageManager->createMessage()
  2. Place the Twig os_message_nb_unread somewhere in a template
  3. View that template and observe that the unread message is incremented due to your send message

Expectation:

  • Only the number of messages directed to the authenticated user will be displayed

Problem with orm mapping configuration

Hi.

I'm tring to install OrnicarMessageBundle for my symfony 2.0 project.

I don't know how to configure orm mapping. In the doc there's only a mongo db mapping example. I don't use mongo db, but i use mysql.

Can anyone help me with a configuration code example??

This is my error:
InvalidConfigurationException: The child node "db_driver" at path "ornicar_message" must be configured.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.